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 trialMassimo Ceron
22,372 PointsReplace the hard coded values in the output with the name and email values from the contacts array......
Where's the problem for pass third step? Why compared this message 'I do not see the required output. You should not be modifying the output at this point.'?
my code is:
<?php
//edit this array
$contacts = array('Alena Holligan', 'Dave McFarland', 'Treasure Porth', 'Andrew Chalkley');
echo "<ul>\n";
//$contacts[0] will return 'Alena Holligan' in our simple array of names.
echo "<li>Alena Holligan : alena.holligan@teamtreehouse.com</li>\n";
echo "<li>Dave McFarland : dave.mcfarland@teamtreehouse.com</li>\n";
echo "<li>Treasure Porth : treasure.porth@teamtreehouse.com</li>\n";
echo "<li>Andrew Chalkley : andrew.chalkley@teamtreehouse.com</li>\n";
echo "</ul>\n";
$contacts = array('Alena Holligan', 'Dave McFarland', 'Treasure Porth', 'Andrew Chalkley');
$contacts = array (
array ( 'name' => 'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'),
array ( 'name' => 'Dave McFarland', 'email' => 'dave.mcfarland@teamtreehouse.com'),
array ( 'name' => 'Treasure Porth', 'email' => 'treasure.porth@teamtreehouse.com'),
array ( 'name' => 'Andrew Chalkley', 'email' => 'andrew.chalkley@teamtreehouse.com'),
);
echo "<ul>\n";
echo "<li>" . $contacts[0]["name"] . " : " . $contacts[0]["email"] . "</li>\n";
echo "<li>" . $contacts[1]["name"] . " : " . $contacts[1]["email"] . "</li>\n";
echo "<li>" . $contacts[2]["name"] . " : " . $contacts[2]["email"] . "</li>\n";
echo "<li>" . $contacts[3]["name"] . " : " . $contacts[3]["email"] . "</li>\n";
echo "</ul>\n";
MODERATOR EDITED: Added markdown to the post so the code is readable in the forum. Please refer to the Markdown Cheatsheet to see how to properly post code in the Community Forum :)
Eric Drake
6,339 PointsMassimo,
I'm not entirely sure how the code verification works in the quizzes. My best guess though is that the verifier doesn't like where you have chosen to edit the $contacts array. Try replacing the code on Line 3 with your code from Lines 16-21. Comment out Line 15 or delete it entirely; it isn't necessary. Let me know if that solves your issue.
7 Answers
Michael Johnson
6,340 PointsThis whole part of the course was the worst experience ive had on treehouse so far....
Arikaturika Tumojenko
8,897 PointsWait till you get to the jquery track :p.
dracorex
17,726 PointsYes, very bad exercices. Also the errors are very ambigue (Check the spacing, wtf..)
At least tell me the line or show me the output to compare with what I should get, don't tell me "Check spacing" :|
Jasper Bloem
22,424 PointsHey Massimo,
I think the reason why the challenge didn't accept your answer is because you had to remove the old echo commands. The code you had was right, but since the old echo commands were there the challenge didn't accept it. Sorry for the vague explanation but this is the final answer.
<?php
$contacts = array('Alena Holligan', 'Dave McFarland', 'Treasure Porth', 'Andrew Chalkley');
$contacts = array (
array ( 'name' => 'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'),
array ( 'name' => 'Dave McFarland','email' => 'dave.mcfarland@teamtreehouse.com'),
array ( 'name' => 'Treasure Porth','email' => 'treasure.porth@teamtreehouse.com'),
array ( 'name' => 'Andrew Chalkley','email' => 'andrew.chalkley@teamtreehouse.com')
);
echo "<ul>\n";
echo "<li>" . $contacts[0]['name'], ' : ' . $contacts[0]['email'] . "</li>\n";
echo "<li>" . $contacts[1]['name'], ' : ' . $contacts[1]['email'] . "</li>\n";
echo "<li>" . $contacts[2]['name'], ' : ' . $contacts[2]['email'] . "</li>\n";
echo "<li>" . $contacts[3]['name'], ' : ' . $contacts[3]['email'] . "</li>\n";
echo "</ul>\n";
Oli Collins
2,385 PointsThis shows an error once used.
Jasper Bloem
22,424 PointsHey Oli,
I've retried my code, and it works for me. Challenge task 1 of 3:
<?php
//edit this array
$contacts = array('Alena Holligan', 'Dave McFarland', 'Treasure Porth', 'Andrew Chalkley');
$contacts = array (
array ( 'name' => 'Alena Holligan'),
array ( 'name' => 'Dave McFarland'),
array ( 'name' => 'Treasure Porth'),
array ( 'name' => 'Andrew Chalkley')
);
echo "<ul>\n";
//$contacts[0] will return 'Alena Holligan' in our simple array of names.
echo "<li>Alena Holligan : alena.holligan@teamtreehouse.com</li>\n";
echo "<li>Dave McFarland : dave.mcfarland@teamtreehouse.com</li>\n";
echo "<li>Treasure Porth : treasure.porth@teamtreehouse.com</li>\n";
echo "<li>Andrew Chalkley : andrew.chalkley@teamtreehouse.com</li>\n";
echo "</ul>\n";
Challenge task 2 of 3:
<?php
//edit this array
$contacts = array('Alena Holligan', 'Dave McFarland', 'Treasure Porth', 'Andrew Chalkley');
$contacts = array (
array ( 'name' => 'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'),
array ( 'name' => 'Dave McFarland','email' => 'dave.mcfarland@teamtreehouse.com'),
array ( 'name' => 'Treasure Porth','email' => 'treasure.porth@teamtreehouse.com'),
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>Alena Holligan : alena.holligan@teamtreehouse.com</li>\n";
echo "<li>Dave McFarland : dave.mcfarland@teamtreehouse.com</li>\n";
echo "<li>Treasure Porth : treasure.porth@teamtreehouse.com</li>\n";
echo "<li>Andrew Chalkley : andrew.chalkley@teamtreehouse.com</li>\n";
echo "</ul>\n";
Challenge task 3 of 3:
<?php
$contacts = array('Alena Holligan', 'Dave McFarland', 'Treasure Porth', 'Andrew Chalkley');
$contacts = array (
array ( 'name' => 'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'),
array ( 'name' => 'Dave McFarland','email' => 'dave.mcfarland@teamtreehouse.com'),
array ( 'name' => 'Treasure Porth','email' => 'treasure.porth@teamtreehouse.com'),
array ( 'name' => 'Andrew Chalkley','email' => 'andrew.chalkley@teamtreehouse.com')
);
echo "<ul>\n";
echo "<li>" . $contacts[0]['name'], ' : ' . $contacts[0]['email'] . "</li>\n";
echo "<li>" . $contacts[1]['name'], ' : ' . $contacts[1]['email'] . "</li>\n";
echo "<li>" . $contacts[2]['name'], ' : ' . $contacts[2]['email'] . "</li>\n";
echo "<li>" . $contacts[3]['name'], ' : ' . $contacts[3]['email'] . "</li>\n";
echo "</ul>\n";
Make sure you replace everything each time!
Markus Mönch
16,383 Pointsecho "<li>" . $contacts[3]['name'], ' : ' . $contacts[3]['email'] . "</li>\n";
why you make , after $contacts[3]['name'] and not " ."
Fabian Pijpers
Courses Plus Student 41,372 PointsThanks for letting me know otherwise i would have been stuck forever in this tredmill.
Ben Stallwood
12,020 PointsTook a while on this question aswell. It looked all right to me but didn't have the spaces in the ' : ', was getting very annoyed as I thought everything was right. Haha.
Massimo Ceron
22,372 PointsThanks for all, I solved.
Tafadzwa Bara
1,175 Pointsecho "<ul>\n"; echo "<li>" . $contacts[0]['name'], ' : ' . $contacts[0]['email'] . "</li>\n"; echo "<li>" . $contacts[1]['name'], ' : ' . $contacts[1]['email'] . "</li>\n"; echo "<li>" . $contacts[2]['name'], ' : ' . $contacts[2]['email'] . "</li>\n"; echo "<li>" . $contacts[3]['name'], ' : ' . $contacts[3]['email'] . "</li>\n"; echo "</ul>\n"; There should only be a single list of contacts. Replace the values, do not duplicate the list. please hejlp
Carlos Alberto Del Cueto Carrejo
13,817 PointsCarlos Alberto Del Cueto Carrejo
13,817 PointsI am trying to understand your question , could you please update the question with the link to the test so I can give it a go. Right now I can only guess that from line 7 through 10 you should use the $contacts array to print out the names. You are redefining $contacts on line 13 and 14, but on line 13 you don't change any of the values from line 3.