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