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) "咸鸭蛋"
}
}
第八條 哪裡怎麼多了個& 怎麼去掉&尼?
解決方案是永遠不要用&
或老實按照官網的指示,用unset解除引用
參考(之前提問): /q/10...
參考2(用&導致的「異常」行為): https://3v4l.org/hlJda
foreach ($good_info as $key => &$val) {
這個 & 是什麼意思呢