Created
March 4, 2013 22:59
-
-
Save noelmcavoy/5086444 to your computer and use it in GitHub Desktop.
Retain previous foreach value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$previous = null; | |
foreach($arr as $ar) { | |
echo $ar; | |
if ($previous) { | |
echo $previous; | |
} | |
$previous = $ar; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment