PHP - Adding array to another array


For array_unshift() and array_push(), you include an array as one of the values to add, the array is added to the original array as an element.

It will turn the original array into a multidimensional array:



$authors = array("A","B","C","D");
$newAuthors = array("Hardy","M");
echo array_push($authors, $newAuthors)."\n"; // Displays"5"

print_r($authors);/*  w w  w .j  a v a 2 s .  c  o m*/



Related Topic