PHP Foreach Preserves Last Item

I thought I’d blog this because it’s something that comes as a surprise to me, so it may come as a surprise to you. Let’s consider this code: http://pastebin.com/mxsjMdij

The second time the loop runs it actually preserves the value of the “$app” variable, and thus triggers the if statement’s isset() function to true.

This issue caught me for a loop for a while, but I guess now I know…. interesting PHP….

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s