3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $list = array("A","B","C","D"); echo "Array current foreach value as variable expression\n"; debug_zval_dump($list); foreach ( $list as $index => $var ) { echo "Iteration #$index:\n"; debug_zval_dump($list); print(current($list)); } echo "\nArray current foreach value as function parameter\n"; debug_zval_dump($list); foreach ( $list as $var ) { echo "Iteration #$index:\n"; print(item($list)); } function item($list) { debug_zval_dump($list); return current($list); } echo "\nArray as function parameter:\n"; item2($list); function item2($list) { debug_zval_dump($list); foreach ( $list as $var ) { echo "Iteration #$index:\n"; debug_zval_dump($list); print(current($list)); } } ?>
Output for 7.1.0
Array current foreach value as variable expression array(4) refcount(3){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #1: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #2: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Array current foreach value as function parameter array(4) refcount(3){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(5){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(3) } A
Output for 7.0.0 - 7.0.14
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } Iteration #0: array(4) refcount(3){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #1: array(4) refcount(3){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #2: array(4) refcount(3){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(3){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } Iteration #3: array(4) refcount(4){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Array as function parameter: array(4) refcount(3){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(4) } A
Output for 5.4.0 - 5.6.28
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(3){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } BIteration #1: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } BIteration #2: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } BIteration #3: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } B Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } BIteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } CIteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } DIteration #3: array(4) refcount(5){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(4) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(4) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(5) } A
Output for 5.2.4 - 5.3.29
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } BIteration #1: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } BIteration #2: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } BIteration #3: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } B Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } BIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } CIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } DIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(4) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(4) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(5) } A
Output for 5.2.1 - 5.2.3
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #1: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #2: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(6){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(4) } A
Output for 5.0.4 - 5.2.0
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #1: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #2: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(4) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(4) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(5) } A
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.3
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #1: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #2: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } A Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(4) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(4) [3]=> string(1) "D" refcount(4) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(5) } A
Output for 4.3.10 - 4.4.0, 4.4.2 - 4.4.9
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #1: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } AIteration #2: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(2) } AIteration #3: array(4) refcount(2){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(3) } A Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } AIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } A Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(3) } A Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(2){ [0]=> string(1) "A" refcount(3) [1]=> string(1) "B" refcount(3) [2]=> string(1) "C" refcount(3) [3]=> string(1) "D" refcount(3) } A
Output for 4.4.1
Array current foreach value as variable expression array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Iteration #0: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } BIteration #1: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } CIteration #2: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(1) } DIteration #3: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Array current foreach value as function parameter array(4) refcount(2){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(2) } Iteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } BIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } CIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } DIteration #3: array(4) refcount(6){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Array as function parameter: array(4) refcount(4){ [0]=> string(1) "A" refcount(1) [1]=> string(1) "B" refcount(1) [2]=> string(1) "C" refcount(1) [3]=> string(1) "D" refcount(1) } Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } B Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } C Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) } D Notice: Undefined variable: index in /in/37R4u on line 35 Iteration #: array(4) refcount(4){ [0]=> string(1) "A" refcount(2) [1]=> string(1) "B" refcount(2) [2]=> string(1) "C" refcount(2) [3]=> string(1) "D" refcount(2) }