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 trialMohamed Mokhtar
9,651 Pointsthe preview displays as it should if iam not wrong and still can not pass the challenge
asking me to view all the list items on this format "Book title (isbn) " i am viewing it and it looks legit but still can not pass the challenge here is my code
<?php foreach($books as $isbn => $book) { ?>
<li><?php echo $book . "\n" . "(" . $isbn . ")"; ?></li>
<?php } ?>
1 Answer
Mohamed Mokhtar
9,651 Pointsnever mind , solved had to do it this way
<?php echo $book; ?> (<?php echo $isbn; ?>)
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Mohamed,
I think the string concatenation would have worked like this:
<li><?php echo $book . " (" . $isbn . ")"; ?></li>
Rather than a line return you want to make sure there's a space after the book.
Perhaps your solution is more readable though.
Mohamed Mokhtar
9,651 PointsMohamed Mokhtar
9,651 PointsHi Jason , i tried your code but yet did not work , tho i have seen another post on the forum suggesting the same solution .. got no clue why it did not work with me really
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Mohamed,
Not sure why the string concatenation is not working for you.
I have just passed with all of the following:
<li><?php echo $book . " (" . $isbn . ")"; ?></li>
or
<li><?php echo $book; ?> (<?php echo $isbn; ?>)</li>
or
<li><?php echo "$book ($isbn)"; ?></li>