xref: /PHP-7.4/Zend/tests/007.phpt (revision 782352c5)
1--TEST--
2each() tests
3--FILE--
4<?php
5
6var_dump(each());
7$var = 1;
8var_dump(each($var));
9$var = "string";
10var_dump(each($var));
11$var = array(1,2,3);
12var_dump(each($var));
13$var = array("a"=>1,"b"=>2,"c"=>3);
14var_dump(each($var));
15
16$a = array(1);
17$a [] =&$a[0];
18
19var_dump(each($a));
20
21
22echo "Done\n";
23?>
24--EXPECTF--
25Warning: each() expects exactly 1 parameter, 0 given in %s on line %d
26NULL
27
28Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
29
30Warning: Variable passed to each() is not an array or object in %s on line %d
31NULL
32
33Warning: Variable passed to each() is not an array or object in %s on line %d
34NULL
35array(4) {
36  [1]=>
37  int(1)
38  ["value"]=>
39  int(1)
40  [0]=>
41  int(0)
42  ["key"]=>
43  int(0)
44}
45array(4) {
46  [1]=>
47  int(1)
48  ["value"]=>
49  int(1)
50  [0]=>
51  string(1) "a"
52  ["key"]=>
53  string(1) "a"
54}
55array(4) {
56  [1]=>
57  int(1)
58  ["value"]=>
59  int(1)
60  [0]=>
61  int(0)
62  ["key"]=>
63  int(0)
64}
65Done
66