key_basic.phpt 695 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test key() function : basic functionality
  3. --FILE--
  4. <?php
  5. /*
  6. * Test basic functionality of key()
  7. */
  8. echo "*** Testing key() : basic functionality ***\n";
  9. $array = array ('zero', 99 => 'one', 'two', 'three' => 3);
  10. echo "\n-- Initial Position: --\n";
  11. var_dump(key($array));
  12. echo "\n-- Next Position: --\n";
  13. next($array);
  14. var_dump(key($array));
  15. echo "\n-- End Position: --\n";
  16. end($array);
  17. var_dump(key($array));
  18. echo "\n-- Past end of the array --\n";
  19. next($array);
  20. var_dump(key($array));
  21. ?>
  22. --EXPECT--
  23. *** Testing key() : basic functionality ***
  24. -- Initial Position: --
  25. int(0)
  26. -- Next Position: --
  27. int(99)
  28. -- End Position: --
  29. string(5) "three"
  30. -- Past end of the array --
  31. NULL