我有一个数组结构,如下所示:
$families = array
(
"Griffin"=>array
(
"Father" => "Peter",
"Mother" => "Lois",
"Child" => "Megan"
),
"Brown"=>array
(
"Father" => "Cleveland",
"Mother" => "Loretta",
"Child" => "Junior"
)
);
我的问题是:
如何使用“Homer”,“Marge”和“Bart”作为数据,将另一个名为“Simpsons”的数组添加到此结构中?
谢谢你们......
答案 0 :(得分:5)
$families['Simpsons'] = array(
'Father' => 'Homer',
'Mother' => 'Marge',
'Child' => 'Bart'
);
答案 1 :(得分:1)
你添加Griffin
和布朗的方式相同。如果您稍后在代码中执行此操作:
$families['Simpsons'] = array('Mother' => 'Marge','Father' =>'Homer','Child' => 'Bart');