Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Arrays and Control Structures PHP Arrays Multidimensional Arrays

Error- " Bummer! I do not see the required output. You should not be modifying the output at this point."

I do not see where I am going wrong. Multidimensional arrays. Help!!!

index.php
<?php
//edit this array
$contacts = [
  $contacts[0] = ['name' => 'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'],
  $contacts[1] = ['name' => 'Dave McFarland', 'email' => 'dave.mcfarland@teamtreehouse.com'],
  $contacts[2] = ['name' => 'Treasure Porth', 'email' => 'treasure.porth@teamtreehouse.com'],
  $contacts[3] = ['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[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";

1 Answer

andren
andren
28,538 Points

Challenges are extremely picky about text output, it usually has to match the expected output exactly as specified.

In your case the issue is that on this line:

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

You are missing a space before the : inside the string

And on this line:

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

You have two spaces before the : instead of one.

If you fix those spacing issues like this:

<?php
//edit this array
$contacts = [
  $contacts[0] = ['name' => 'Alena Holligan', 'email' => 'alena.holligan@teamtreehouse.com'],
  $contacts[1] = ['name' => 'Dave McFarland', 'email' => 'dave.mcfarland@teamtreehouse.com'],
  $contacts[2] = ['name' => 'Treasure Porth', 'email' => 'treasure.porth@teamtreehouse.com'],
  $contacts[3] = ['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[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";

Then your code will pass.

Worked like a charm!!! Thank you Andren.