Zweifel an der PHP-Array-Verarbeitung
我想大声告诉你
我想大声告诉你 2017-07-01 09:11:51
0
2
724
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) "咸鸭蛋"
  }
}

Artikel 8 Warum gibt es ein zusätzliches & und wie entferne ich &?

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

Antworte allen(2)
给我你的怀抱

解决方案是永远不要用&

或者老老实实按照官网的指示,用unset解除引用

<?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
?>

参考(之前提问): /q/10...
参考2(用&导致的“异常”行为): https://3v4l.org/hlJda

学习ing

foreach ($good_info as $key => &$val) {
这个 & 是什么意思呢

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage