RE: [PHP-DEV] PHP 4.0 Bug #4522: Recursive array_merge() support
| From: | Nathan Cassano | Date: | Thu, 25 May 2000 21:09:26 +0000 |
| Subject: | RE: [PHP-DEV] PHP 4.0 Bug #4522: Recursive array_merge() support | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-19445@lists.php.net to get a copy of this message | ||
> From: nathan@cjhunter.com
> Operating system: Linux 2.2.14
> PHP version: 4.0 Release Candidate 1
> PHP Bug Type: Feature/Change Request
> Bug description: Recursive array_merge() support
>
> If a key from two arrays is the same in an array_merge() function,
sub merge those two key's values. array_merge() currently just
replaces the other key.
>
> Here is an example of the current behavior.
>
> $a = array("x" => array(1,2,3));
> $b = array("x" => array(4,5,6));
How would you submerge if you had the following situation:
$a = array("x" => array(1,2,3));
$b = array("x" => 9);
I would convert the mixed type variables into a single element arrays
and then merge the two arrays.
$a = array("x" => array(1,2,3));
$b = array("x" => 9);
array_merge($a, $b);
/* $b becomes array("x" => array(9)) */
array(1) {
["x"]=>
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(9)
}
}