<?php
$one = array(
'4158' => array(
'raw' => 'something',
'rendered' => 'something else',
),
'foo' => 'string',
'bar' => array(
'key' => 'value',
'baz' => 100,
),
);
$two = array(
'4158' => array(
'protected' => 'has a password',
),
'bar' => array(
'zzz' => 'yo',
),
'go' => 'Cubs',
);
$temp = $one + (array) $two;
var_dump( $temp );
- Output for 5.6.0 - 5.6.27, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- array(4) {
[4158]=>
array(2) {
["raw"]=>
string(9) "something"
["rendered"]=>
string(14) "something else"
}
["foo"]=>
string(6) "string"
["bar"]=>
array(2) {
["key"]=>
string(5) "value"
["baz"]=>
int(100)
}
["go"]=>
string(4) "Cubs"
}
preferences:
60.04 ms | 408 KiB | 5 Q