I'm probably thinking about this the wrong way, but I'm still getting un-dumb about while loops...
My script looks like this:
$match_pattern = 'some_pattern';
$dh = opendir('my_directory_path');
while (false !== ($file = readdir($dh)))
{
// go thru all files in upload directory
if (preg_match($match_pattern, $file))
{
// do something
break;
}
}
This is great as long as there's a match for my pattern, but if there is no match I'd like to execute a different process.
Should I start with a condition like "$match_found = false", and switch it to "true" if a match is found? Or is there a slicker way to do it?