1--TEST-- 2foreach() with references 3--FILE-- 4<?php 5 6$arr = array(1 => "one", 2 => "two", 3 => "three"); 7 8foreach($arr as $key => $val) { 9 $val = $key; 10} 11 12print_r($arr); 13 14foreach($arr as $key => &$val) { 15 $val = $key; 16} 17 18print_r($arr); 19?> 20--EXPECT-- 21Array 22( 23 [1] => one 24 [2] => two 25 [3] => three 26) 27Array 28( 29 [1] => 1 30 [2] => 2 31 [3] => 3 32) 33