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

Paypal Quiz Issue

In Build a Simple PHP Application > Integrating with PayPal > Forms, Arrays, and Get Variables In the following question: What does the following block of code output? <?php $flavors = array("Cake Batter","Cookie Dough"); foreach ($flavors as $a => $b) { echo $b; exit; } ?>

It accepts "Cake Batter" instead of "Cake BatterCookie Dough".

2 Answers

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

The answer is Cake Batter.

Notice the exit in the foreach loop? We've talked about the exit command a few different times, including the video Checking the Request Method, 2:40-2:50.

I got stuck on this one too. The foreach goes through one time then exits. Took me a bit to concentrate and understand this.