xref: /PHP-7.4/ext/standard/tests/array/006.phpt (revision 31e1cd13)
1--TEST--
2Test array_pop behaviour
3--FILE--
4<?php
5
6array_pop($GLOBALS);
7
8$a = array("foo", "bar", "fubar");
9$b = array("3" => "foo", "4" => "bar", "5" => "fubar");
10$c = array("a" => "foo", "b" => "bar", "c" => "fubar");
11
12/* simple array */
13echo array_pop($a), "\n";
14array_push($a, "foobar");
15var_dump($a);
16
17/* numerical assoc indices */
18echo array_pop($b), "\n";
19var_dump($b);
20
21/* assoc indices */
22echo array_pop($c), "\n";
23var_dump($c);
24
25?>
26--EXPECT--
27fubar
28array(3) {
29  [0]=>
30  string(3) "foo"
31  [1]=>
32  string(3) "bar"
33  [2]=>
34  string(6) "foobar"
35}
36fubar
37array(2) {
38  [3]=>
39  string(3) "foo"
40  [4]=>
41  string(3) "bar"
42}
43fubar
44array(2) {
45  ["a"]=>
46  string(3) "foo"
47  ["b"]=>
48  string(3) "bar"
49}
50