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--EXPECTF--
33*** Testing each() : usage variations ***
34
35-- Array made up of referenced variables: --
36-- Call each until at the end of the array: --
37
38Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
39array(4) {
40  [1]=>
41  string(3) "foo"
42  ["value"]=>
43  string(3) "foo"
44  [0]=>
45  string(3) "one"
46  ["key"]=>
47  string(3) "one"
48}
49array(4) {
50  [1]=>
51  string(3) "bar"
52  ["value"]=>
53  string(3) "bar"
54  [0]=>
55  int(0)
56  ["key"]=>
57  int(0)
58}
59bool(false)
60Done
61