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 Build a Simple PHP Application Integrating with PayPal Array Keys

I have no idea what wrong in my code, I preview the display is conform with the question requirement.

I don't know what is wrong, but I got this message:

Bummer! I see all the book titles and the ISBNs in the browser, but the formatting is not quite right. Each list item should look like this: Book Title (978-0123456789)

books.php
<?php

$books["978-0743261690"] = "Gilgamesh";
$books["978-0060931957"] = "The Odyssey";
$books["978-0192840509"] = "Aesop's Fables";
$books["978-0520227040"] = "Mahabharta";
$books["978-0393320978"] = "Beowulf";

?><html>
<head>
    <title>Five Great Books</title>
</head>
<body>
    <h1>Five Great Books</h1>
    <ul>
        <?php foreach($books as $isbn => $book) { ?>
            <li><?php echo $book . " (" . $isbn . ") "; ?></li>
        <?php } ?>
    </ul>
</body>
</html>

2 Answers

Liam Maclachlan
Liam Maclachlan
22,805 Points

Is it the extra space after the closing parenthesis?

        <?php foreach($books as $isbn => $book) { ?>
            <li><?php echo $book . " (" . $isbn . ") "; ?></li>
        <?php } ?>

Should be

        <?php foreach($books as $isbn => $book) { ?>
            <li><?php echo $book . " (" . $isbn . ")"; ?></li>
        <?php } ?>

I really hope that is all it is :)

Thank you so much, that's exactly the answer! :)

Liam Maclachlan
Liam Maclachlan
22,805 Points

No problem, man.

That can be quite dictatorial on the presentation of printed and echoed code. Always worth checking syntax and then spacing with these types of questions.

Remember to hit up 'best answer' on your resolved questions :)

Oliver Gibbs
Oliver Gibbs
9,771 Points

That's annoying it's not being accepted - I copied and pasted your code into a test page and it's definitely outputting the list correctly to the screen. Like Liam says maybe it's just that trailing space.

Thank you! exactly, the trailing space make me get wrong. :P