summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2003-07-24 13:21:54 +0000
committerZeev Suraski <zeev@php.net>2003-07-24 13:21:54 +0000
commit95eaf55aa666fdb90b94bfdb6381b94ccbd4ec09 (patch)
tree69aca8230a4f442706cde918f6b48be7e570dc74 /tests
parentd326b809988eed8508459e8f2599219740e3f084 (diff)
downloadphp-git-95eaf55aa666fdb90b94bfdb6381b94ccbd4ec09.tar.gz
Add foreach() test with references
Diffstat (limited to 'tests')
-rw-r--r--tests/lang/foreach_with_references_001.phpt32
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
+)