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

duncan borg
duncan borg
1,243 Points

formatting issues

im not sure how the formatting is needed to be done on the second question this is my code

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

    <?php } ?>

it displays as it suggests when i hit recheck but it still tells me that i am wrong

2 Answers

Hi Duncan,

It's hard to make out the formatting when the html tags have been stripped out.

Here's some tips on how to post code in the forums: https://teamtreehouse.com/forum/posting-code-to-the-forum

The book and isbn are wrapped in an li. Make sure you don't have a space before the book name or a space after the closing ) on the isbn.

<li><?php echo $book;?> (<?php echo $isbn;?>)</li>
Michael Collins
Michael Collins
433 Points

Curly Brackets are control characters inside of PHP code blocks. Below, the curly brackets define the function code block. Where curly brackets start and end INSIDE of PHP code is very very important.

<?php

function frogger() {

}
?>

Outside of PHP code areas, the curly brackets are just any other character. How many you use and in what order doesn't matter except in terms of visual output.

<?php echo "some text"; ?>
} } { { { some more text }}}

<?php echo "final text": ?>

You can also do something like this

<?php

$books = array(

'xxxx' => 'my title'

);

foreach($books as $isbn => $book) { ?>

  <?php echo $book; ?>


<?php

}

?>