// In PHP5 foreach loop using reference variable
// Example
$arr = array(2,3,4,5);
print_r($arr); // Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 )
foreach ($arr as &$value) {
if($value == 4) { $value = 77; }
}
print_r($arr); // Array ( [0] => 2 [1] => 3 [2] => 77 [3] => 5 )
Thursday, January 14, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment