0

I have an array structure, like this:

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

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

);

My question is:

How do I add another array called "Simpsons" to this structure with "Homer", "Marge" and "Bart" as the data?

Thanks guys....

1
  • 2
    how the previous elements were added? what have you tried? Commented Oct 26, 2012 at 15:02

2 Answers 2

5
$families['Simpsons'] = array(
  'Father' => 'Homer', 
  'Mother' => 'Marge', 
  'Child'  => 'Bart'
);
Sign up to request clarification or add additional context in comments.

Comments

1

Same way you added Griffin and Brown. If you do this later on in the code:

 $families['Simpsons'] = array('Mother' => 'Marge','Father' =>'Homer','Child' => 'Bart');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.