note 96716 deleted from function.array-merge by danbrown
| From: | danbrown@php.net | Date: | Fri, 12 Mar 2010 14:33:15 +0000 |
| Subject: | note 96716 deleted from function.array-merge by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166967@lists.php.net to get a copy of this message | ||
Note Submitter: Thales Jacobi
----
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