note 96716 added to function.array-merge
| From: | ThalesJacobi at osu1 dot php dot net | Date: | Fri, 12 Mar 2010 14:28:41 +0000 |
| Subject: | note 96716 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166966@lists.php.net to get a copy of this message | ||
Yeah riddlemd, thanks for that. I was merging two arrays and one of them had a sequence of numbers
that didn't start with [0], like:
$first_array=>Array(
[1] => Array([key1]=>value1)
[2] => Array([key2]=>value2));
$second_array=>Array(
[a] => Array([keya]=>valuea)
[b] => Array([keyb]=>valueb));
$main_array=array_merge($first_array,$second_array);
# Outputs
[0] => Array([key1]=>value1)// undesired reset
[1] => Array([key2]=>value2)// undesired reset
[a] => Array([keya]=>valuea)
[b] => Array([keyb]=>valueb);
--To fix that
$first_array+=$second_array;
Very cool solution
----
Server IP: 87.124.86.47
Probable Submitter: 81.149.30.53 (proxied: 81.149.30.53)
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/96716
Del: integrated -- https://master.php.net/note/delete/96716/integrated
Del: useless -- https://master.php.net/note/delete/96716/useless
Del: bad code -- https://master.php.net/note/delete/96716/bad+code
Del: spam -- https://master.php.net/note/delete/96716/spam
Del: non-english -- https://master.php.net/note/delete/96716/non-english
Del: in docs -- https://master.php.net/note/delete/96716/in+docs
Del: other reasons-- https://master.php.net/note/delete/96716
Reject -- https://master.php.net/note/reject/96716
Search -- https://master.php.net/manage/user-notes.php