Created
November 19, 2010 21:19
-
-
Save jessegreathouse/707195 to your computer and use it in GitHub Desktop.
php you vex me.
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
<?php | |
//a list of unknown size | |
$bars=array(); | |
// I want to walk through the array and take the first one that isn't empty | |
//this code looks wierd but it's a compromise. | |
foreach ($bars as $bar) { if ($foo = $bar) { break 1; } | |
//this is what i wanted to do | |
while (!$foo = current($bars)) { | |
next($bars); | |
} | |
//Im trying to say if $referrer isn't null to keep the loop open until current returns a non empty | |
//The problem is that this type of while loop seems to only work if im testing for a positive instead | |
//of a negative because the negative just keeps the loop open forever. | |
//is my compromise the only adequate solution? | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment