テストソース1:
$test = array( 1, 2, 3, 4, 5); foreach ($test as &$value) {} foreach ($test as $value) {} print_r($test);
結果1:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 4 )
テストソース2:
$test = array( 1, 2, 3, 4, 5); foreach ($test as &$value) {} $value = 99999; print_r($test);
結果2:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 99999 )
テストソース3:
$test = array( 1, 2, 3, 4, 5); foreach ($test as &$value) {} unset($value); // 変数初期化 $value = 99999; print_r($test);
結果3:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )