Checkout the substr() function. You can do something like: if (substr($var, -9) = '_1111.jpg')) { // do something }
-9 would be the staring position. I am not sure if this is the right number, so you will have to look at the manual :-) -- Julio Nobrega. Um dia eu chego lá: http://sourceforge.net/projects/toca Ajudei? Salvei? Que tal um presentinho? http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884 "Jas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > Here is an example of the files in the directory... > willies_0411.jpg > watson_0411.jpg > willies_logo.jpg > watson_logo.jpg > etc.. > When I remove the eregi() it works fine, all the files are displayed, > however I only want the files ending in _1111.jpg to be displayed in the > select box and well I did another one using a sting to filter out all files > except _logo.jpg and it works fine, I just can't get the _1111.jpg files to > display. Also the directory is fine, I have the same function being called > in two places one to display only *_logo.jpg files and the second to display > only *_1111.jpg files the number one doesnt seem to work so I may just > create two directories for the two types I need, but I would rather get this > sting function down so I can use it elsewhere on our site. Any help would > be great... > Jas > > "Erik Price" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > On Friday, April 12, 2002, at 01:50 AM, jas wrote: > > > > > Ok, I have tried all 3 examples and even tried a few variations that you > > > have given me and so far nothing is getting displayed, is there a way to > > > check for errors? here is the code I am working with: > > > > What happens if you get rid of that eregi() function? Does it show you > > all of your files? If so, then the problem is the regex in your eregi(). > > > > > > > // 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=\"images\"> > > > <SELECT NAME=\"images\">"; > > > while ($file_names = readdir($dir)) { > > > if ($file_names != "." && $file_names !=".." && > > > eregi("^/*_[0-9]{4}\.jpg$", $file_name)) { > > ^^^^^^^^^^^^^^^^^^ > > This regex will match only files that obey the following rules: > > 1. may or may not start with a slash > > 2. next character must be an underscore > > 3. next 4 characters must be digits > > 4. next character must be a dot > > 5. next 3 characters must be "jpg" > > 6. case doesn't matter > > > > Are you sure you have files that meet the above 6 rules in your > > directory? If you don't, then nothing will be displayed. Are you sure > > that your "/path/to/directory" is a real path to a real directory? etc > > etc > > > > > > > $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); > > > > > > > > > > > > Erik > > > > > > > > ---- > > > > Erik Price > > Web Developer Temp > > Media Lab, H.H. Brown > > [EMAIL PROTECTED] > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php