跪求大佬解惑
<?php
$data = [['name'=>'John','age'=>25],['name'=>'Mary','age'=>30],['name'=>'Peter','age'=>20]];
foreach ($data as &$value) {
echo "Name: ".$value['name']." Age: ".$value['age'];
}
foreach ($data as $value) {
echo "Name: ".$value['name']." Age: ".$value['age']."\n\r";
}
有没有大佬帮忙解惑
输出结果为
浏览器:
Name: John Age: 25Name: Mary Age: 30Name: Peter Age: 20
Name: John Age: 25 Name: Mary Age: 30 Name: Mary Age: 30
循序并没有改变任何数值,为什么第二个的循环输出结果变了
推荐文章: