array_merge_basic.phpt 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Test array_merge() function : basic functionality
  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. * Test basic functionality of array_merge()
  11. */
  12. echo "*** Testing array_merge() : basic functionality ***\n";
  13. //indexed array
  14. $array1 = array ('zero', 'one', 'two');
  15. //associative array
  16. $array2 = array ('a' => 1, 'b' => 2, 'c' => 3);
  17. var_dump(array_merge($array1, $array2));
  18. var_dump(array_merge($array2, $array1));
  19. echo "Done";
  20. ?>
  21. --EXPECTF--
  22. *** Testing array_merge() : basic functionality ***
  23. array(6) {
  24. [0]=>
  25. string(4) "zero"
  26. [1]=>
  27. string(3) "one"
  28. [2]=>
  29. string(3) "two"
  30. ["a"]=>
  31. int(1)
  32. ["b"]=>
  33. int(2)
  34. ["c"]=>
  35. int(3)
  36. }
  37. array(6) {
  38. ["a"]=>
  39. int(1)
  40. ["b"]=>
  41. int(2)
  42. ["c"]=>
  43. int(3)
  44. [0]=>
  45. string(4) "zero"
  46. [1]=>
  47. string(3) "one"
  48. [2]=>
  49. string(3) "two"
  50. }
  51. Done