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 trialAndres Vicente
1,665 PointsIn the code below, we have a simple array of contact names. We want to use the $contacts array to fill in the hardcoded
syntax error, unexpected '" . : alena.holligan@teamtreeh' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in index.php on line 7
<?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> . $contacts[0] , " " . : alena.holligan@teamtreehouse.com</li>\n";
echo "<li> . $contacts[1] , " " . : dave.mcfarland@teamtreehouse.com</li>\n";
echo "<li> . $contacts[2] , " " . : treasure.porth@teamtreehouse.com</li>\n";
echo "<li> . $contacts[3] , " " . : andrew.chalkley@teamtreehouse.com</li>\n";
echo "</ul>\n";
1 Answer
koltton fox
2,576 PointsExtremely poor written question on Tree House!!
Daniel PΓ©rez
13,402 PointsDaniel PΓ©rez
13,402 PointsHello Andres
Try to separate the string from the array. If you echo "<li>" then you have to concatenate the value in the array by using the dot operator, like this: echo "<li>" . $contacts[0] . "</li>";
If you do not want to cancatenate the string with the value of the array, you can pass the value of the array to a variable and add it inside the string, like this: $contacName = $contacts[0]; echo "<li> $contactName </li>";
Because when you use double quotes, PHP can interpret the value of the variable.
I hope it helps.