note 116903 added to function.array-merge-recursive

From: Date: Tue, 17 Mar 2015 17:01:00 +0000
Subject: note 116903 added to function.array-merge-recursive
Groups: php.notes 
Request: Send a blank email to php-notes+get-201974@lists.php.net to get a copy of this message
Attention. (used PHP 5.4. XAMPP) Values with numeric keys are always appended. The index of the merge array is determined by the startindex of the first array. Value4s with numeric keys seems always appended. If a key looks like an integer, array_merge_recursive will interpret the string as an number. In the example $arr['farbe']['22'] = 'grün' wil be found after array_merge_recursive in $res['farbe'][33] $ar1 = array("farbe" => array (31 => 'holla', "rot", "favorit" => "gelb2"), "favorit" => "gelb1", 5); $ar2 = array(10, "farbe" => array ('22' => "grün", "favorit" => 2, "blau")); $result = array_merge_recursive ($ar1, $ar2); var_dump($result); echo('<hr>'); // var_dump array(4) { ["farbe"]=> array(5) { [31]=> string(5) "holla" [32]=> string(3) "rot" ["favorit"]=> array(2) { [0]=> string(5) "gelb2" [1]=> int(2) } [33]=> string(5) "grün" [34]=> string(4) "blau" } ["favorit"]=> string(5) "gelb1" [0]=> int(5) [1]=> int(10) } ---- Server IP: 72.52.91.14 Probable Submitter: 79.222.247.74 ---- Manual Page -- http://php.net/manual/en/function.array-merge-recursive.php Edit -- https://master.php.net/note/edit/116903 Del: integrated -- https://master.php.net/note/delete/116903/integrated Del: useless -- https://master.php.net/note/delete/116903/useless Del: bad code -- https://master.php.net/note/delete/116903/bad+code Del: spam -- https://master.php.net/note/delete/116903/spam Del: non-english -- https://master.php.net/note/delete/116903/non-english Del: in docs -- https://master.php.net/note/delete/116903/in+docs Del: other reasons-- https://master.php.net/note/delete/116903 Reject -- https://master.php.net/note/reject/116903 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201974) next »