Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Arrays and Control Structures PHP Arrays Multidimensional Arrays

*[SOLVED]* Issues with understanding a task.

Would you please help me understand what is required on a task. The task itself is: "In the code below, we have a simple array of contact names. We want to use the $contacts array to fill in the hardcoded list of names an email addresses. To hold the email as well as the name for each contact, we need a multidimensional array, meaning each person in the contact list will have their own array. The first step is to make each person their own single item ASSOCIATIVE array, using 'name' as the key for these internal arrays." And I am not able to understand, by saying that we should make an array for each person and use the key '''name'', does it refer to each of their names as a different key, or simply "name" as an universal one. But if it is the second, doesn't this overwrite each previous array within the multidimensional one? Also, should we include the emails as well and for this, should we use a separate key, such as 'email'? So far I have this idea:

<?php

$contacts[]= array( 'name' => 'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'; ); $contacts[] = array( 'name' => 'Dave McFarland', 'email' => 'dave.mcfarland@teamtreehouse.com' ); $contacts[] = array( 'name' => 'Treasure Porth', 'email' => 'dave.mcfarland@teamtreehouse.com' ) $contacts[] = array( 'name' => 'Andrew Chalkley', 'email' => 'andrew.chalkley@teamtreehouse.com'; );

?>

1 Answer

I've managed to solve it and understood it. Thank you if you have taken the time to start answering, but there would be no further need. Apologies and best regards, Ioan.