note 92232 rejected from language.operators.array by thiago

From: Date: Wed, 15 Jul 2009 12:06:13 +0000
Subject: note 92232 rejected from language.operators.array by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158332@lists.php.net to get a copy of this message
Note Submitter: maverickwest at nexgo dot de ---- What about array addition, if the array elements are multidimensional arrays? $array1 = array( array('id'=>1,'name'=>'John'), array('id'=>2,'name'=>'Fritz') ); $array2 = array( array('id'=>4,'name'=>'Emma'), array('id'=>7,'name'=>'Johanna') ); if i try array_merge or $array1 + $array2 the result only contains the value of the first array. What i want to have is simply one array with all element of both arrays like that array(4) { [0]=> array(2) { ["id"]=> int(1) ["name"]=> string(4) "John" } [1]=> array(2) { ["id"]=> int(2) ["name"]=> string(5) "Fritz" } [2]=> array(2) { ["id"]=> int(4) ["name"]=> string(4) "Emma" } [3]=> array(2) { ["id"]=> int(7) ["name"]=> string(7) "Johanna" } } i get this if i do something like that foreach( $array2 as $value ) { $array1[] = $value; } is there any better or easier way to get the goal? THX in advanced mav

« previous php.notes (#158332) next »