> -----Original Message-----
> From: Boyd, Todd M. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 10, 2008 8:28 AM
> To: [email protected]
> Subject: RE: Re: [PHP] file_exists and wildcard/regex
>
> FWIW, I would probably do the file search like this (UNTESTED):
>
> <?php
>
> $filereg = '/bfile[1-9]?\d+\.txt/i';
Erp. I meant '/bfile[1-9]?\d\.txt/i', with no '+' after the '\d'... assuming
you want 0-99 to be the range of values.
> $pathstr = '/whatever/your/path/is';
>
> if(is_dir($pathstr)) {
> if($dir = opendir($pathstr)) {
> $found = false;
>
> while(($file = readdir($dir)) !== false && !$found) {
> if(preg_match($filereg, $file) > 0) {
> echo $file . '<br />';
> $found = true;
> }
> }
>
> closedir($dir);
> }
> }
>
> ?>
// Todd