1--TEST--
2Test each() function : basic functionality
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 basic functionality of each()
13 */
14
15echo "*** Testing each() : basic functionality ***\n";
16
17$arr = array ('one' => 1, 'zero', 'two' => 'deux', 20 => 'twenty');
18echo "\n-- Passed array: --\n";
19var_dump($arr);
20
21echo "\n-- Initial position: --\n";
22var_dump(each($arr));
23
24echo "\n-- End position: --\n";
25end($arr);
26var_dump(each($arr));
27
28echo "\n-- Passed the end of array: --\n";
29var_dump(each($arr));
30
31echo "Done";
32?>
33--EXPECTF--
34*** Testing each() : basic functionality ***
35
36-- Passed array: --
37array(4) {
38  ["one"]=>
39  int(1)
40  [0]=>
41  string(4) "zero"
42  ["two"]=>
43  string(4) "deux"
44  [20]=>
45  string(6) "twenty"
46}
47
48-- Initial position: --
49
50Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
51array(4) {
52  [1]=>
53  int(1)
54  ["value"]=>
55  int(1)
56  [0]=>
57  string(3) "one"
58  ["key"]=>
59  string(3) "one"
60}
61
62-- End position: --
63array(4) {
64  [1]=>
65  string(6) "twenty"
66  ["value"]=>
67  string(6) "twenty"
68  [0]=>
69  int(20)
70  ["key"]=>
71  int(20)
72}
73
74-- Passed the end of array: --
75bool(false)
76Done
77