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 PHP Arrays and Control Structures PHP Arrays Multidimensional Arrays

Jordan Crone
Jordan Crone
5,486 Points

I answer task1 correct, proceed to step2, answer step2 correct, and check test 3 and it says task1 is no longer passing

For some reason it is modifying my original code which is <?php

$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');

echo "<ul>\n"; //$contacts[0] will return 'Alena Holligan' in our simple array of names. echo "<li>" . $contacts[0]['name'] . ":" .$contacts[0]['email'] . "</li>\n"; echo "<li>" . $contacts[0]['name'] . ":" .$contacts[0]['email'] ."</li>\n"; echo "<li>" . $contacts[0]['name'] . ":" .$contacts[0]['email'] . "</li>\n"; echo "<li>" . $contacts[0]['name'] . ":" .$contacts[0]['email']. "</li>\n"; echo "</ul>\n";

?>

Antonio De Rose
Antonio De Rose
20,885 Points

when you cope paste your coding, please follow the markdown sheet, it will help the readers.

2 Answers

Benjamin Larson
Benjamin Larson
34,055 Points

Jordan -

Sometimes the error message do not accurately indicate where the problem is, and in this challenge, pasting code from the final completed challenge into a fresh reloaded version won't even allow it to pass the first task.

You're code was not far off, however. There were two things I found that you needed to change-

  1. Add spaces before and after the ":" in between the names and email addresses.
  2. Modify your references to the contacts[0] to change with each respective user (contacts[1], contacts[2], etc.)
Jordan Crone
Jordan Crone
5,486 Points

Thanks ben, I actually had the numbered keys originally but forgot to change them when posting this question, but had overlooked the spaces between the colons. I realized after submitting this that there is a separate support contact for bugs, which I was trying to report originally. Thanks for taking the time to respond though