Re: eregi() problems...

From: Date: Tue, 16 Apr 2002 07:24:49 +0000
Subject: Re: eregi() problems...
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-93138@lists.php.net to get a copy of this message
the rest seems ok to me, if you search for files with e.g hello_2222.jpg as name "Michael Virnstein" <michael.virnstein@brodos.de> schrieb im Newsbeitrag news:20020416072143.32968.qmail@pb1.pair.com... > eregi('_[0-9]{4}.jpg$', $file_name) > > should be > > eregi('_[0-9]{4}\.jpg$', $file_name) > > . is a spcial character(means every character) and has to be backslashed if > you want it's normal meaning > > > "Jas" <jlgerfen@hotmail.com> schrieb im Newsbeitrag > news:20020415212633.63563.qmail@pb1.pair.com... > > I must be doing something wrong, for that solution did not work. > > > > "Robert Cummings" <robert.cummings@webmotion.com> wrote in message > > news:3CBB2D74.A8CA0852@webmotion.com... > > > jas wrote: > > > > > > > > // second selection for main image on main page > > > > $dir_name = "/path/to/images/directory/"; > > > > $dir = opendir($dir_name); > > > > $file_lost .= "<p><FORM METHOD=\"post\" > > > > ACTION=\"done.php3\" > > NAME=\"ad01\"> > > > > <SELECT NAME=\"images\">"; > > > > while ($file_names = readdir($dir)) { > > > > if ($file_names != "." && $file_names !=".." > > > > && > > eregi('_[0-9]{4}.jpg$', > > > > $file_name)) { > > > > $file_lost .= "<OPTION VALUE=\"$file_names\" > > > > NAME=\"$file_names\">$file_names</OPTION>"; > > > > } > > > > } > > > > $file_lost .= "</SELECT><br><br><INPUT > > > > TYPE=\"submit\" > NAME=\"submit\" > > > > VALUE=\"select\"></FORM></p>"; > > > > closedir($dir); > > > > > > > > My problem is with the eregi() function to filter out files without > the > > > > following criteria *_4444.jpg, it must have an underscore followed by > 4 > > > > numbers and then ending in .jpg file extension. I have tried a few > > > > different methods to try and get this to work however I think I am > > missing > > > > something. All of the documentation I have read on php.net states > that > > this > > > > string should work as is... I have checked the contents of the > directory > > and > > > > I only have files of these two types... > > > > filename_logo.jpg > > > > filename_0103.jpg > > > > Could anyone enlighten me on how this is not working? > > > > Thanks in advance, > > > > > > I hope I'm reading right... it seems you want to filter OUT files with > > > the extension '_4444.jpg' the above check appears to be filtering out > > > everything BUT these files. I think you want the following check: > > > > > > if( $file_names != "." > > > && > > > $file_names !=".." > > > && > > > !eregi( '_[0-9]{4}\.jpg$', $file_name) ) > > > > > > Cheers, > > > Rob. > > > -- > > > .-----------------. > > > | Robert Cummings | > > > :-----------------`----------------------------. > > > | Webdeployer - Chief PHP and Java Programmer | > > > :----------------------------------------------: > > > | Mail : mailto:robert.cummings@webmotion.com | > > > | Phone : (613) 731-4046 x.109 | > > > :----------------------------------------------: > > > | Website : http://www.webmotion.com | > > > | Fax : (613) 260-9545 | > > > `----------------------------------------------' > > > > > >

« previous php.general (#93138) next »