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!
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
gabriel wambua5,061 Points
What am I doing wrong?
I felt for sure that this code would work. I am however getting an error telling me that there should only be 2 levels of arrays. The main array and 4 other arrays set inside the main array.
The code looks sound. What am I doing wrong?
<?php $contacts = array( "alena"=>array( 'name'=> 'Alena Holigan', 'email'=>'firstname.lastname@example.org' ), "dave"=>array( 'name'=> 'Dave McFarland', 'email'=>'email@example.com' ), "Treasure"=>array( 'name'=> 'Treasure Porth', 'email'=>'firstname.lastname@example.org' ), "Andrew"=>array( 'name'=> 'Andrew Chalkle', 'email'=>'email@example.com' ));
Jennifer NordellTreehouse Teacher
Hi there, gabriel wambua ! Looks like you're off to a terrific start, but that's not quite what they're asking for. First, you are assigning everything to the 0 index of
$contacts, but each index of
$contacts should be an array. Secondly, you're providing a key that isn't being asked for. Third, on Andrew Chalkley's name you have a misspelling of their name and also on Alena Holligan. Let's take a look at how I might start that array, which is actually very similar to your code:
<?php $contacts = array( array( 'name'=> 'Alena Holligan', 'email'=>'firstname.lastname@example.org' ),
Continue in this pattern, but check again the spelling of "Alena Holigan" which is what you have vs "Alena Holligan" and "Andrew Chalkle" (your version) and "Andrew Chalkley" (the correct spelling).
Hope this helps!