0

我有一个数组结构,如下所示:

$families = array
(
    "Griffin"=>array
    (
        "Father" => "Peter",
        "Mother" => "Lois",
        "Child" => "Megan"
    ),

    "Brown"=>array
    (
        "Father" => "Cleveland",
        "Mother" => "Loretta",
        "Child" => "Junior"
    )

);

我的问题是:

如何以“Homer”、“Marge”和“Bart”为数据将另一个名为“Simpsons”的数组添加到该结构中?

多谢你们....

4

2 回答 2

5
$families['Simpsons'] = array(
  'Father' => 'Homer', 
  'Mother' => 'Marge', 
  'Child'  => 'Bart'
);
于 2012-10-26T15:02:40.590 回答
1

与您添加Griffin和布朗的方式相同。如果您稍后在代码中执行此操作:

 $families['Simpsons'] = array('Mother' => 'Marge','Father' =>'Homer','Child' => 'Bart');
于 2012-10-26T15:03:40.900 回答