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 Sorting Arrays

Aaron Coursolle
Aaron Coursolle
18,014 Points

Stage 3 of Arrays within Arrays Challenge

"I'm asking here because the code challenge button is disabled"

Hi, I'm able to pass stage one and stage two, but at stage three I am getting an error. I believe I am following the instructions as they are presented.

Replace the hard coded values in the output with the name and email values from the contacts array.

Here is the original:

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";

and here is what I changed:

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";

And here is the error:

I do not see the required output. You should not be modifying the output at this point.

I'm confused with the wording of the error because that is exactly what we are supposed to do in Stage 3. Anyway, the other two levels passed but I will add the complete code, as a comment, in case if my mistake is not in the echo statements. P.S. We haven't covered loops yet, hence the long list of echo statements.

Aaron Coursolle
Aaron Coursolle
18,014 Points

link to challenge: https://teamtreehouse.com/library/php-arrays-and-control-structures/php-arrays/multidimensional-arrays

<?php
//edit this array
//$contacts = array('Alena Holligan', 'Dave McFarland', 'Treasure Porth', 'Andrew Chalkley');
$contacts[] = [
  'name' => 'Alena Holligan',
  'email' => 'alena.holligan@teamtreehouse.com',
];

$contacts[] = [
  'name' => 'Dave McFarland',
  'email' => 'dave.mcfarland@teamtreehouse.com',
];

$contacts[] = [
  'name' => 'Treasure Porth',
  'email' => 'treasure.porth@teamtreehouse.com',
];

$contacts[] = [
  '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";

?>

You mentioned the code challenge button isn't working.

There's a "Get Help" button on the code challenge page. That's not working for you?

What happens when you click on it?

Aaron Coursolle
Aaron Coursolle
18,014 Points

The "Get Help" button is working now. Before, when I pressed it, nothing changed.

1 Answer

Hi Aaron,

The original output only had a single space on either side of the colon.

You put 2 spaces on the right side of the colon which is causing the output not to match exactly.