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

Chris Wood
Chris Wood
3,591 Points

Why won't this work on step 3 of the code challenge for multidimensional arrays?

In the third step it ask you to replace the hard coded output with the values in the array. I originally came up with this:

echo "<li>",implode(" : ",$contacts[0]),"</li>\n";
echo "<li>",implode(" : ",$contacts[1]),"</li>\n";
echo "<li>",implode(" : ",$contacts[2]),"</li>\n";
echo "<li>",implode(" : ",$contacts[3]),"</li>\n";

but could not complete the challenge until I did this:

echo "<li>".$contacts[0]['name'];echo " : ".$contacts[0]['email'];echo"</li>\n";
echo "<li>".$contacts[1]['name'];echo " : ".$contacts[1]['email'];echo"</li>\n";
echo "<li>".$contacts[2]['name'];echo " : ".$contacts[2]['email'];echo"</li>\n";
echo "<li>".$contacts[3]['name'];echo " : ".$contacts[3]['email'];echo"</li>\n";

Can anyone explain the difference between these two if there is any? They both looked the same in the output to me. Was this just treehouse being nit picky or is there a real difference between the two.

Thanks

Sorry for the delay, can you post the challenge this is referring too.