xref: /PHP-7.2/ext/standard/tests/array/bug36975.phpt (revision 17ccbeec)
1--TEST--
2Bug #36975 (natcasesort() causes array_pop() to misbehave)
3--FILE--
4<?php
5$a = array('aa', 'aa', 'bb', 'bb', 'cc', 'cc');
6$test = natcasesort($a);
7if ($test) {
8  echo "natcasesort success!\n";
9}
10$val = array_pop($a);
11$a[] = $val;
12var_dump($a);
13
14$b = array(1 => 'foo', 0 => 'baz');
15array_pop($b);
16$b[] = 'bar';
17array_push($b, 'bar');
18print_r($b);
19
20$c = array(0, 0, 0, 0, 0);
21asort($c);
22array_pop($c);
23$c[] = 'foo';
24$c[] = 'bar';
25var_dump($c);
26?>
27--EXPECT--
28natcasesort success!
29array(6) {
30  [0]=>
31  string(2) "aa"
32  [1]=>
33  string(2) "aa"
34  [2]=>
35  string(2) "bb"
36  [3]=>
37  string(2) "bb"
38  [4]=>
39  string(2) "cc"
40  [5]=>
41  string(2) "cc"
42}
43Array
44(
45    [1] => foo
46    [2] => bar
47    [3] => bar
48)
49array(6) {
50  [0]=>
51  int(0)
52  [1]=>
53  int(0)
54  [2]=>
55  int(0)
56  [3]=>
57  int(0)
58  [4]=>
59  string(3) "foo"
60  [5]=>
61  string(3) "bar"
62}
63