diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lang/foreach_with_references_001.phpt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lang/foreach_with_references_001.phpt b/tests/lang/foreach_with_references_001.phpt new file mode 100644 index 0000000000..eb52bb8c10 --- /dev/null +++ b/tests/lang/foreach_with_references_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +foreach() with references +--FILE-- +<?php + +$arr = array(1 => "one", 2 => "two", 3 => "three"); + +foreach($arr as $key => $val) { + $val = $key; +} + +print_r($arr); + +foreach($arr as $key => &$val) { + $val = $key; +} + +print_r($arr); + +--EXPECT-- +Array +( + [1] => one + [2] => two + [3] => three +) +Array +( + [1] => 1 + [2] => 2 + [3] => 3 +) |
