<?php$arr = ['1', '2', '3', '4'];foreach ($arr as &$i) {}echo implode($arr, ', ')."\n"; //1,2,3,4foreach ($arr as $i) {}echo implode($arr, ', ')."\n"; //1,2,3,3?>
$arr = ['1', '2', '3', '4']; foreach ($arr as &$i) {}echo implode($arr, ', ')."\n"; //1,2,3,4 foreach ($arr as $i) { echo '*' . join(',', $arr), PHP_EOL;}echo implode($arr, ', ')."\n"; //1,2,3,3
1, 2, 3, 4*1,2,3,1*1,2,3,2*1,2,3,3*1,2,3,31, 2, 3, 3在笫二个 foreach 中,由于 $i 是 $arr 最后一个元素的引用
明白了,谢谢