array_merge_variation5.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. --TEST--
  2. Test array_merge() function : usage variations - numeric keys
  3. --FILE--
  4. <?php
  5. /* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
  6. * Description: Merges elements from passed arrays into one array
  7. * Source code: ext/standard/array.c
  8. */
  9. /*
  10. * Pass array_merge() arrays with only numeric keys to test behaviour.
  11. * $arr2 contains a duplicate element to $arr1.
  12. */
  13. echo "*** Testing array_merge() : usage variations ***\n";
  14. //numeric keys
  15. $arr1 = array('zero', 'one', 'two', 'three');
  16. $arr2 = array(1 => 'one', 20 => 'twenty', 30 => 'thirty');
  17. var_dump(array_merge($arr1, $arr2));
  18. var_dump(array_merge($arr2, $arr1));
  19. echo "Done";
  20. ?>
  21. --EXPECTF--
  22. *** Testing array_merge() : usage variations ***
  23. array(7) {
  24. [0]=>
  25. string(4) "zero"
  26. [1]=>
  27. string(3) "one"
  28. [2]=>
  29. string(3) "two"
  30. [3]=>
  31. string(5) "three"
  32. [4]=>
  33. string(3) "one"
  34. [5]=>
  35. string(6) "twenty"
  36. [6]=>
  37. string(6) "thirty"
  38. }
  39. array(7) {
  40. [0]=>
  41. string(3) "one"
  42. [1]=>
  43. string(6) "twenty"
  44. [2]=>
  45. string(6) "thirty"
  46. [3]=>
  47. string(4) "zero"
  48. [4]=>
  49. string(3) "one"
  50. [5]=>
  51. string(3) "two"
  52. [6]=>
  53. string(5) "three"
  54. }
  55. Done