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 trialJeremy Osborn
15,999 PointsPlease tell me what I'm doing wrong on this question. I've tried to call the values every way I know how.
When i check the code it just says Bummer: Try Again!; immensely unhelpful feedback. haha
<?php
//edit this array
$contacts = array(['name' =>'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'],
['name' =>'Dave McFarland', 'email' => 'dave.mcfarland@teamtreehouse.com'],
['name' =>'Treasure Porth', 'email' => 'treasure.porth@teamtreehouse.com'],
['name' =>'Andrew Chalkley', 'email' => 'andrew.chalkley@teamtreehouse.com']);
echo "<ul>\n";
//$contacts[0] will return 'Alena Holligan' in our simple array of names.
echo $contacts[0]['name'];
echo $contacts[0]['email'];
echo $contacts[1]['name'];
echo $contacts[1]['email'];
echo $contacts[2]['name'];
echo $contacts[2]['email'];
echo $contacts[3]['name'];
echo $contacts[3]['email'];
echo "</ul>\n";
2 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsIt looks like you're trying to list each value of the array one by one instead of putting them in strings.
I'm not sure which part of the challenge you're stuck with but I think it's task 3?
You may need to go back through or reset the challenge to get the strings back. When you do, you'll need replace some parts of the string with the values in the array. You can do this with concatenation, which incase you don't know yet means combining multiple strings into one.
e,.g.
<?php echo "<li>" + $contacts[0]["name"] + " : " + $contacts[0]["email"] + "</li>\n";
Jeremy Osborn
15,999 PointsThanks!
I had actually figured the missing "<li>" tags out just before you sent me this. I was frustrated because the challenge was to correctly call the values within the array (which I did) but I haven't had much HTML at this point so the tags escaped my focus and I couldn't figure out how to correctly concatenate the string.