array_shift_variation7.phpt 830 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. Test array_shift() function : usage variations - position of internal pointer
  3. --FILE--
  4. <?php
  5. /* Prototype : mixed array_shift(array &$stack)
  6. * Description: Pops an element off the beginning of the array
  7. * Source code: ext/standard/array.c
  8. */
  9. /*
  10. * Test that the internal pointer is reset after calling array_shift()
  11. */
  12. echo "*** Testing array_shift() : usage variations ***\n";
  13. $stack = array ('one' => 'un', 'two' => 'deux');
  14. echo "\n-- Call array_shift() --\n";
  15. var_dump($result = array_shift($stack));
  16. echo "\n-- Position of Internal Pointer in Passed Array: --\n";
  17. echo key($stack) . " => " . current ($stack) . "\n";
  18. echo "Done";
  19. ?>
  20. --EXPECTF--
  21. *** Testing array_shift() : usage variations ***
  22. -- Call array_shift() --
  23. string(2) "un"
  24. -- Position of Internal Pointer in Passed Array: --
  25. two => deux
  26. Done