..


Sponsored Links

array_merge

Array_merge function is used to join two or more arrays into a new array. Here's an example:






 $ Fruits = array ('apple', 'pear', 'fishing');







 $ Vegetables = array ('carrot', 'tomato', 'potato');









 / / Join the two arrays







 $ Spent = array_merge ($ fruits, $ vegetables);



The result will be a new array with six elements.

Warning: If two or more elements have the same key, the last one overwrites the previous. Example:





 $ Arr1 = array ('a' => 'apple', 'b' => 'pear');







 $ Arr2 = array ('b' => 'carrot', 'c' => 'tomato');







 print_r (array_merge ($ arr1, $ arr2));



This will output:
 



 Array (



  



 [A] => apple



  



 [B] => carrot



  



 [C] => tomato







 )

 

In the same category ...
E-Learning
Linux (Course) Linux (Course)
Complete guide to open-source system. From 49 €.
MySQL (Course) MySQL (Course)
Management of open-source database. From 39 €.
PHP (Course) PHP (Course)
Full course for creating dynamic Web sites. From 49 €.
Sponsored Links