Doubts about php array processing
我想大声告诉你
我想大声告诉你 2017-07-01 09:11:51
0
2
708
foreach ($good_info as $key => &$val) {
            $val['g_num'] = $vv[$key];
            $val['ware_Beizu'] = $bb[$key];

        }
[7]=>
  array(15) {
    ["id"]=>
    string(4) "1170"
    ["g_name"]=>
    string(12) "日本豆腐"
    ["g_images"]=>
    string(72) "http://xlddc.zkd.com/Public/Uploads/goods/2017-06-29/595450d5db86a.jpg"
    ["g_price"]=>
    string(1) "0"
    ["g_attr"]=>
    string(7) "90g/根"
    ["g_cd"]=>
    string(6) "中国"
    ["g_desc"]=>
    string(0) ""
    ["g_count"]=>
    string(3) "998"
    ["g_sum"]=>
    string(1) "1"
    ["g_cat"]=>
    string(3) "878"
    ["is_on_sale"]=>
    string(1) "1"
    ["g_sn"]=>
    string(5) "13033"
    ["g_cont"]=>
    NULL
    ["g_num"]=>
    string(1) "1"
    ["ware_Beizu"]=>
    string(12) "日本豆腐"
  }
  [8]=>
  &array(15) {
    ["id"]=>
    string(4) "1175"
    ["g_name"]=>
    string(9) "咸鸭蛋"
    ["g_images"]=>
    string(72) "http://xlddc.zkd.com/Public/Uploads/goods/2017-06-29/595456e6e0c73.jpg"
    ["g_price"]=>
    string(1) "0"
    ["g_attr"]=>
    string(3) "只"
    ["g_cd"]=>
    string(6) "中国"
    ["g_desc"]=>
    string(0) ""
    ["g_count"]=>
    string(3) "997"
    ["g_sum"]=>
    string(1) "2"
    ["g_cat"]=>
    string(3) "879"
    ["is_on_sale"]=>
    string(1) "1"
    ["g_sn"]=>
    string(10) "0401002002"
    ["g_cont"]=>
    NULL
    ["g_num"]=>
    string(1) "1"
    ["ware_Beizu"]=>
    string(9) "咸鸭蛋"
  }
}

Article 8 Why is there an extra & and how to remove it?

我想大声告诉你
我想大声告诉你

reply all(2)
给我你的怀抱

The solution is never to use it&

Or just follow the instructions on the official website and use unset to dereference

<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
    $value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
unset($value); // break the reference with the last element
?>

Reference (previous question): /q/10...
Reference 2 ("abnormal" behavior caused by using &): https://3v4l.org/hlJda

学习ing

foreach ($good_info as $key => &$val) {
What does this & mean?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template