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

Sebastian Popa
Sebastian Popa
11,094 Points

Can i get the code for this code challenge ?

I need the code that makes this challenge work.

index.php
<?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";
Jason Anders
Jason Anders
Treehouse Moderator 145,631 Points

Hi Karlheinz,

I don't see any of your code yet? I only see the pre-loaded code for the challenge. You should also post the code you are trying so other may help you troubleshoot where you could be going wrong.

The Community is a place to come for help with code. It's really not a place where answers are just given out, as this does not contribute to a positive learning environment for yourself or for others.

Please give the challenge a 'good-faith' try and then post your code. This way other students will be able to assist in figuring out the challenge.

Thank-you :)

:dizzy:

Sebastian Popa
Sebastian Popa
11,094 Points

Jason Anders english is not my first language and the problem is the i don t understand what the task wants . I mean i have no clue what is the target , it s the first time when i have such problem . I didn 't post any code because i can't understand what i need to do . That s why i m asking for the entire code . After i get the result i should be able to understand what was the task . So if you still think it s not ok for positive learning as you said , please email the answer at <removed by Moderator>@gmail.com .

Thank you so much !

Sebastian Popa
Sebastian Popa
11,094 Points

i tried something but it doesn't work , and it only says " Bummer! Try again ! " Jason Anders

<?php
//edit this array
$one = array( "name" => 'Alena Holligan' );
$two = array ( "name" => 'Dave McFarland');
$three = array ( "name" => 'Treasure Porth');
$four = array ( "name" => ' Andrew Chalckley ');
$contacts = array($one, $two, $three, $four);
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";

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,631 Points

Hi again :)

You're on the right track in that the task wants individual arrays, but the arrays should all be inside the first array, instead of each being assigned to its own variable (so creating a multi-dimensional array).
So, you pretty much have all the correct syntax, :thumbsup: the arrays need to me moved into one, like this:

$contacts = array(
          array('name' => 'Alena Holligan'), 
          array('name' => 'Dave McFarland'), 
          array('name' => 'Treasure Porth'), 
          array('name' => 'Andrew Chalkley')
);

Hope this helps. :smiley:

Keep Coding! :dizzy: