Is it possible to append to a nested array from within an outer layer of that array?
<?php
$x = array
(
'test' => array('asd', 'works'),
'blah' => $x['test'] + array('more')
);
print_r($x);
?>
Basically, is it possible for 'b开发者_如何学Clah' to have the contents of 'test'?
This is not possible in the circular way you have. However, you could do the following to achieve the desired result.
$x = array
(
'test' => array('asd', 'works')
);
$x['blah'] = $x['test'];
array_push($x['blah'], 'more');
print_r($x);
you cannot do it while declaring the array.
however, you can assign the same values with a different key.
精彩评论