reset_basic.phpt 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Test reset() function : basic functionality
  3. --FILE--
  4. <?php
  5. /* Prototype : mixed reset(array $array_arg)
  6. * Description: Set array argument's internal pointer to the first element and return it
  7. * Source code: ext/standard/array.c
  8. */
  9. /*
  10. * Test basic functionality of reset()
  11. */
  12. echo "*** Testing reset() : basic functionality ***\n";
  13. $array = array('zero', 'one', 200 => 'two');
  14. echo "\n-- Initial Position: --\n";
  15. echo key($array) . " => " . current($array) . "\n";
  16. echo "\n-- Call to next() --\n";
  17. var_dump(next($array));
  18. echo "\n-- Current Position: --\n";
  19. echo key($array) . " => " . current($array) . "\n";
  20. echo "\n-- Call to reset() --\n";
  21. var_dump(reset($array));
  22. ?>
  23. ===DONE===
  24. --EXPECTF--
  25. *** Testing reset() : basic functionality ***
  26. -- Initial Position: --
  27. 0 => zero
  28. -- Call to next() --
  29. string(3) "one"
  30. -- Current Position: --
  31. 1 => one
  32. -- Call to reset() --
  33. string(4) "zero"
  34. ===DONE===