Php 将关联数组添加到数组-如何?
我有一个数组结构,如下所示:Php 将关联数组添加到数组-如何?,php,arrays,Php,Arrays,我有一个数组结构,如下所示: $families = array ( "Griffin"=>array ( "Father" => "Peter", "Mother" => "Lois", "Child" => "Megan" ), "Brown"=>array ( "Father" => "Cleveland", "Mother" =&g
$families = array
(
"Griffin"=>array
(
"Father" => "Peter",
"Mother" => "Lois",
"Child" => "Megan"
),
"Brown"=>array
(
"Father" => "Cleveland",
"Mother" => "Loretta",
"Child" => "Junior"
)
);
我的问题是:
如何将另一个名为“辛普森一家”的数组添加到此结构中,并将“荷马”、“玛姬”和“巴特”作为数据
谢谢大家……就像你们添加的
Griffin
和Brown一样。如果稍后在代码中执行此操作:
$families['Simpsons'] = array(
'Father' => 'Homer',
'Mother' => 'Marge',
'Child' => 'Bart'
);
$families['Simpsons'] = array('Mother' => 'Marge','Father' =>'Homer','Child' => 'Bart');
与您添加的
Griffin
和Brown的方式相同。如果稍后在代码中执行此操作:
$families['Simpsons'] = array('Mother' => 'Marge','Father' =>'Homer','Child' => 'Bart');
如何添加以前的元素?您尝试过什么?如何添加以前的元素?你试过什么?