xref: /PHP-7.3/ext/standard/tests/array/bug21918.phpt (revision 610c7fbe)
1--TEST--
2Bug #21918 (different handling of positive vs. negative array indexes)
3--FILE--
4<?php
5
6echo "==Mixed==\n";
7$a = array(-1=>'a', '-2'=>'b', 3=>'c', '4'=>'d', 5=>'e', '6001'=>'f', '07'=>'g');
8
9foreach($a as $k => $v) {
10	var_dump($k);
11	var_dump($v);
12}
13
14echo "==Normal==\n";
15$b = array();
16$b[] = 'a';
17
18foreach($b as $k => $v) {
19	var_dump($k);
20	var_dump($v);
21}
22
23echo "==Negative==\n";
24$c = array('-2' => 'a');
25
26foreach($c as $k => $v) {
27	var_dump($k);
28	var_dump($v);
29}
30
31echo "==Done==\n";
32?>
33--EXPECT--
34==Mixed==
35int(-1)
36string(1) "a"
37int(-2)
38string(1) "b"
39int(3)
40string(1) "c"
41int(4)
42string(1) "d"
43int(5)
44string(1) "e"
45int(6001)
46string(1) "f"
47string(2) "07"
48string(1) "g"
49==Normal==
50int(0)
51string(1) "a"
52==Negative==
53int(-2)
54string(1) "a"
55==Done==
56