array_values_variation7.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Test array_values() function : usage variations - Internal order check
  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. * Check that array_values is re-assigning keys according to the internal order of the array,
  11. * and is not dependent on the \$input argument's keys
  12. */
  13. echo "*** Testing array_values() : usage variations ***\n";
  14. // populate array with 'default' keys in reverse order
  15. $input = array(3 => 'three', 2 => 'two', 1 => 'one', 0 => 'zero');
  16. echo "\n-- \$input argument: --\n";
  17. var_dump($input);
  18. echo "\n-- Result of array_values() --\n";
  19. var_dump(array_values($input));
  20. echo "Done";
  21. ?>
  22. --EXPECT--
  23. *** Testing array_values() : usage variations ***
  24. -- $input argument: --
  25. array(4) {
  26. [3]=>
  27. string(5) "three"
  28. [2]=>
  29. string(3) "two"
  30. [1]=>
  31. string(3) "one"
  32. [0]=>
  33. string(4) "zero"
  34. }
  35. -- Result of array_values() --
  36. array(4) {
  37. [0]=>
  38. string(5) "three"
  39. [1]=>
  40. string(3) "two"
  41. [2]=>
  42. string(3) "one"
  43. [3]=>
  44. string(4) "zero"
  45. }
  46. Done