Created
July 27, 2019 01:38
-
-
Save parzibyte/c77f094cc81772fea232979f680b24f4 to your computer and use it in GitHub Desktop.
Manual array merge in PHP https://parzibyte.me/blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://parzibyte.me/blog | |
$gatos = array("Michi", "Misifú"); | |
$perros = array("Maggie", "Guayaba"); | |
# Creamos el resultado, que al principio es el primer arreglo | |
$mascotas = $gatos; | |
// Al que vamos a adjuntar lo recorremos | |
foreach ($perros as $perro) { | |
// Y en cada paso, agregamos el valor al otro | |
array_push($mascotas, $perro); | |
} | |
print_r($mascotas); | |
/* | |
Array | |
( | |
[0] => Michi | |
[1] => Misifú | |
[2] => Maggie | |
[3] => Guayaba | |
) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment