如果if为if,则执行代码,否则执行if

时间:2017-01-05 09:34:12

标签: mysql codeigniter

此代码执行if和else,任何帮助将不胜感激,谢谢你。

  foreach($each_item as $key => $product)
  {
    foreach($new_item as $key2 => $newproduct)
    {
      if (in_array($product['product_id'], $newproduct)) {
        $this->update_order_items($order_id, $product['product_id'], array(
            "quantity" => $newproduct['quantity'], 
            "price" => $newproduct['price']       
            ));
      }
      else
      {
        $this->delete_order_items($order_id, $product['product_id']);
      }
    }
  }

1 个答案:

答案 0 :(得分:0)

您能否告诉我们上述代码的结果?

foreach($each_item as $key => $product)
  {
    foreach($new_item as $key2 => $newproduct)
    {
      if (in_array($product['product_id'], $newproduct)) {
        echo '1';
      }
      else
      {
       echo '2'; 
      }
      exit;
    }
  }