1--TEST--
2Test each() function : usage variations - Referenced variables
3--FILE--
4<?php
5/* Prototype  : array each(array $arr)
6 * Description: Return the currently pointed key..value pair in the passed array,
7 * and advance the pointer to the next element
8 * Source code: Zend/zend_builtin_functions.c
9 */
10
11/*
12 * Test behaviour of each() when:
13 * 1. Passed an array made up of referenced variables
14 * 2. Passed an array as $arr argument by reference
15 */
16
17echo "*** Testing each() : usage variations ***\n";
18
19echo "\n-- Array made up of referenced variables: --\n";
20$val1 = 'foo';
21$val2 = 'bar';
22
23$arr1 = array('one' => &$val1, &$val2);
24
25echo "-- Call each until at the end of the array: --\n";
26var_dump( each($arr1) );
27var_dump( each($arr1) );
28var_dump( each($arr1) );
29
30echo "Done";
31?>
32
33--EXPECTF--
34*** Testing each() : usage variations ***
35
36-- Array made up of referenced variables: --
37-- Call each until at the end of the array: --
38array(4) {
39  [1]=>
40  string(3) "foo"
41  ["value"]=>
42  string(3) "foo"
43  [0]=>
44  string(3) "one"
45  ["key"]=>
46  string(3) "one"
47}
48array(4) {
49  [1]=>
50  string(3) "bar"
51  ["value"]=>
52  string(3) "bar"
53  [0]=>
54  int(0)
55  ["key"]=>
56  int(0)
57}
58bool(false)
59Done
60