array_pop_variation.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --TEST--
  2. Test array_pop() function (variation)
  3. --FILE--
  4. <?php
  5. /* Various combinations of arrays to be used for the test */
  6. $mixed_array = array(
  7. array(),
  8. array( 1,2,3,4,5,6,7,8,9 ),
  9. array( "One", "_Two", "Three", "Four", "Five" ),
  10. array( 6, "six", 7, "seven", 8, "eight", 9, "nine" ),
  11. array( "a" => "aaa", "A" => "AAA", "c" => "ccc", "d" => "ddd", "e" => "eee" ),
  12. array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
  13. array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
  14. array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF",
  15. "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
  16. array( 12, "name", 'age', '45' ),
  17. array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
  18. array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
  19. 5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 )
  20. );
  21. echo"\n*** Checking for internal array pointer being reset when pop is called ***\n";
  22. echo "\nCurrent Element is : ";
  23. var_dump( current($mixed_array[1]) );
  24. echo "\nNext Element is : ";
  25. var_dump( next($mixed_array[1]) );
  26. echo "\nNext Element is : ";
  27. var_dump( next($mixed_array[1]) );
  28. echo "\nPOPed Element is : ";
  29. var_dump( array_pop($mixed_array[1]) );
  30. echo "\nCurrent Element after POP operation is: ";
  31. var_dump( current($mixed_array[1]) );
  32. echo"\nDone";
  33. ?>
  34. --EXPECTF--
  35. *** Checking for internal array pointer being reset when pop is called ***
  36. Current Element is : int(1)
  37. Next Element is : int(2)
  38. Next Element is : int(3)
  39. POPed Element is : int(9)
  40. Current Element after POP operation is: int(1)
  41. Done