foreach遍历数组一个容易忽略的小错误,你曾经犯过没?
<?php /** * 注意foreach取值的差异 */ $arr = array(1,2,3,4); echo "foreach遍历数组1: "; foreach($arr as $val) { $val = $val*2; } var_dump($arr); echo " foreach遍历数组2: "; foreach($arr as &$val) { $val = $val*2; } var_dump($arr); /*end of php*/