array_values_variation5.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Test array_values() function : usage variations - internal array pointer
  3. --FILE--
  4. <?php
  5. /* Prototype : array array_values(array $input)
  6. * Description: Return just the values from the input array
  7. * Source code: ext/standard/array.c
  8. */
  9. /*
  10. * Test the position of the internal array pointer after a call to array_values
  11. */
  12. echo "*** Testing array_values() : usage variations ***\n";
  13. $input = array ('one' => 'un', 'two' => 'deux', 'three' => 'trois');
  14. echo "\n-- Call array_values() --\n";
  15. var_dump($result = array_values($input));
  16. echo "-- Position of Internal Pointer in Result: --\n";
  17. echo key($result) . " => " . current($result) . "\n";
  18. echo "\n-- Position of Internal Pointer in Original Array: --\n";
  19. echo key($input) . " => " . current ($input) . "\n";
  20. echo "Done";
  21. ?>
  22. --EXPECTF--
  23. *** Testing array_values() : usage variations ***
  24. -- Call array_values() --
  25. array(3) {
  26. [0]=>
  27. string(2) "un"
  28. [1]=>
  29. string(4) "deux"
  30. [2]=>
  31. string(5) "trois"
  32. }
  33. -- Position of Internal Pointer in Result: --
  34. 0 => un
  35. -- Position of Internal Pointer in Original Array: --
  36. one => un
  37. Done