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 Enhancing a Simple PHP Application Refactoring the Codebase Manipulating an Array

Don Shipley
Don Shipley
19,488 Points

PHP Challenge task 1 of 1

array_revers like $reverse = array_reverse($var) and use the echo $var; This shows as an error unless I use var_dump $var. http://teamtreehouse.com/library/enhancing-a-simple-php-application-2/refactoring-the-codebase/manipulating-an-array This block of code creates an array of ice cream flavors and displays them in ascending order. The owner of the ice cream shop would like this order changed so that the flavors are displayed in descending order instead, starting with Cookie Dough first and Jalapeno So Spicy last. Leave the $flavors array itself in the same order, but modify something else in this code block to achieve that.

Don Shipley
Don Shipley
19,488 Points

For some reason even though I wrote this a few time and told me to check. I copied it from my text editor and pasted it in the test question and worked. <?php $reverse = array_reverse($flavors); $list_html = "" ;
foreach($reverse as $flavor) {
$list_html = $list_html . "<li>"; $list_html = $list_html . $flavor; $list_html = $list_html . "</li>"; }

echo $list_html;

?>

2 Answers

it's the same

Don Shipley
Don Shipley
19,488 Points

Thank you, Yes it is the same, I have no idea why after writing the code it did not pass. I must have done something wrong,