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 trialTetiana lukerievas
5,641 PointsWhat I am doing here wrong?
1) why is this not working:
echo "<li>$contacts['Alena']['name'] : $contacts['Alena']['email']</li>\n";
2) Here is my answer to the test. Why is it not working too if it renders the right answer?
<?php
//edit this array
$contacts = array(
"Alena" => array(
"name" => 'Alena Holligan',
"email" => 'alena.holligan@teamtreehouse.com'
),
"Dave" => array(
"name" => 'Dave McFarland',
"email" => 'dave.mcfarland@teamtreehouse.com'
),
"Treasure" => array(
"name" => 'Treasure Porth',
"email" => 'treasure.porth@teamtreehouse.com'
),
"Andrew" => array(
"name" => 'Andrew Chalkley',
"email" => 'andrew.chalkley@teamtreehouse.com'
),
);
echo "<ul>\n";
//$contacts[0] will return 'Alena Holligan' in our simple array of names.
echo "<li>" . $contacts['Alena']['name'] . ":" . $contacts['Alena']['email'] . "</li>\n";
echo "<li>" . $contacts['Dave']['name'] . ":" . $contacts['Dave']['email'] . "</li>\n";
echo "<li>" . $contacts['Treasure']['name'] . ":" . $contacts['Treasure']['email'] . "</li>\n";
echo "<li>" . $contacts['Andrew']['name'] . ":" . $contacts['Andrew']['email'] . "</li>\n";
echo "</ul>\n";
2 Answers
Henrik Christensen
Python Web Development Techdegree Student 38,322 Pointsyou're missing a space on both sides of the colons
":" // your code
" : " // should be like this
Tetiana lukerievas
5,641 PointsTetiana lukerievas
5,641 PointsBut why is this not working?
"<li>$contacts['Alena']['name'] : $contacts['Alena']['email']</li>\n";
Tetiana lukerievas
5,641 PointsTetiana lukerievas
5,641 PointsI added spaces and now I get "Each person in the contact list should have their own internal array. Use another "array()" for each person."
But the output is the same as in the test result....