Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/07/2009, 09:49
Avatar de Ronruby
Ronruby
 
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: Array_merge_recursive Vs array_merge

En que array_merge_recursive, si hay 2 o mas elementos con la misma llave, los une creando un array.

Usando el ejemplo en el manual para array_merge_recursive:
Código PHP:
<?php
$m1 
= array("color" => array("favorito" => "rojo"), 5);
$m2 = array(10"color" => array("favorito" => "verde""azul"));
$resultado array_merge_recursive($m1$m2);
print_r($resultado);
?>
Usando array_merge_recursive obtenemos:
Código:
Array
(
    [color] => Array
        (
            [favorito] => Array
                (
                    [0] => rojo
                    [1] => verde
                )

            [0] => azul
        )

    [0] => 5
    [1] => 10
)
Con array_merge:
Código:
Array
(
    [color] => Array
        (
            [favorito] => verde
            [0] => azul
        )

    [0] => 5
    [1] => 10
)
http://www.php.net/manual/es/functio...-recursive.php
http://www.php.net/manual/es/function.array-merge.php