Skip to content

Commit 66946a9

Browse files
committed
ext/standard/array.c: add test extracting negative keys
1 parent 0d4fa83 commit 66946a9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
extract() with negative keys
3+
--FILE--
4+
<?php
5+
$a = [-5 => 'hello', 'world', 2 => 'positive', 'check' => 'extracted'];
6+
7+
function foo(array $a) {
8+
extract($a, EXTR_PREFIX_ALL, 'prefix');
9+
var_dump(get_defined_vars());
10+
}
11+
12+
foo($a);
13+
?>
14+
--EXPECT--
15+
array(3) {
16+
["a"]=>
17+
array(4) {
18+
[-5]=>
19+
string(5) "hello"
20+
[-4]=>
21+
string(5) "world"
22+
[2]=>
23+
string(8) "positive"
24+
["check"]=>
25+
string(9) "extracted"
26+
}
27+
["prefix_2"]=>
28+
string(8) "positive"
29+
["prefix_check"]=>
30+
string(9) "extracted"
31+
}

0 commit comments

Comments
 (0)