PHP - Fonction array_merge ()
Syntaxe
array array_merge ( array $array1 [, array $array2 [, array $array3...]] );
Définition et utilisation
Il fusionne les éléments d'un ou plusieurs tableaux afin que les valeurs de l'un soient ajoutées à la fin du précédent.
Paramètres
| Sr.Non | Paramètre et description |
|---|---|
| 1 | array1(Required) Il spécifie un tableau. |
| 2 | array2(Optional) Il spécifie un tableau. |
| 3 | array3(Optional) Il spécifie un tableau. |
Valeurs de retour
Il renvoie le tableau résultant.
Exemple
Essayez l'exemple suivant -
<?php
$input = array("a"=>"Horse","b"=>"Cat","c"=>"Dog");
$input1 = array("d"=>"Cow","a"=>"Cat","e"=>"elephant");
print_r(array_merge($input,$input1));
?>
Cela produira le résultat suivant -
Array ( [a] => Cat [b] => Cat [c] => Dog [d] => Cow [e] => elephant )
