006.phpt 698 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Test array_pop behaviour
  3. --FILE--
  4. <?php
  5. array_pop($GLOBALS);
  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. /* simple array */
  10. echo array_pop($a), "\n";
  11. array_push($a, "foobar");
  12. var_dump($a);
  13. /* numerical assoc indices */
  14. echo array_pop($b), "\n";
  15. var_dump($b);
  16. /* assoc indices */
  17. echo array_pop($c), "\n";
  18. var_dump($c);
  19. ?>
  20. --EXPECT--
  21. fubar
  22. array(3) {
  23. [0]=>
  24. string(3) "foo"
  25. [1]=>
  26. string(3) "bar"
  27. [2]=>
  28. string(6) "foobar"
  29. }
  30. fubar
  31. array(2) {
  32. [3]=>
  33. string(3) "foo"
  34. [4]=>
  35. string(3) "bar"
  36. }
  37. fubar
  38. array(2) {
  39. ["a"]=>
  40. string(3) "foo"
  41. ["b"]=>
  42. string(3) "bar"
  43. }