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 trialMichael Bennett
Courses Plus Student 808 PointsI need help...I can't seem to get past this. I'm stuck on the output for this php array.
Can someone help me with the answer for this? I've tried lots of things and I generate the right output when I preview, but the work doesn't check out.
<?php
//edit this array
$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' => 'treasure.porth@teamtreehouse.com'
);
$contacts[] = array(
'name' => 'Andrew Chalkley',
'email' => 'andrew.chalkley@teamtreehouse.com'
);
$name_alena = 'Alena Holligan';
$email_alena = 'alena.holligan@teamtreehouse.com';
$name_dave = 'Dave McFarland';
$email_dave = 'dave.mcfarland@teamtreehouse.com';
$name_treasure = 'Treasure Porth';
$email_treasure = 'treasure.porth@teamtreehouse.com';
$name_andrew = 'Andrew Chalkley';
$email_andrew = 'andrew.chalkley@teamtreehouse.com';
echo "<ul>\n";
//$contacts[0] will return 'Alena Holligan' in our simple array of names.
echo "<li>$name_alena : $email_alena</li>\n";
echo "<li>$name_dave : $email_dave</li>\n";
echo "<li>$name_treasure : $email_treasure</li>\n";
echo "<li>$name_andrew : $email_andrew</li>\n";
echo "</ul>\n";
1 Answer
Angela Visnesky
20,927 PointsHi Michael! You have a lot of extraneous variables that you don't need for this challenge. Your final line should end up similar to:
echo "<li>$array['name'] . " : " . $array['email']</li>\n";
The idea of using arrays to hold data is to simplify and not repeat yourself. I hope this gets you going in the right direction!