Re: string...
| From: | heinisch at creaction dot de | Date: | Thu, 11 Apr 2002 21:46:26 +0000 |
| Subject: | Re: string... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92670@lists.php.net to get a copy of this message | ||
Aehm,
as I´m a bit old- and shell- stylish (see reply from Rasmus on:How to create...)
why don´t you just make
unset($retval); // cleans the array to contain the resul
exec("ls ".$your_path".*_1111.jpg",$retval,$is_ok); // $retval will be an array containing all matches
if($is_ok)
{
<form bla...
for($i=0; $i < count($retval);$i++)
{
<option...> $retval[$i]</option>
}
<other formstuff...
}
If you want you could put another for loop around it to have your special files
be scanned one after the other.
Or did I missed something 'new' again ? ;-)
HTH Oliver
At 12.04.2002 00:32, you wrote:
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" <pricee@hhbrown.com> wrote in message news:B153C560-4D77-11D6-8DF2-0050E4857868@hhbrown.com... 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 pricee@hhbrown.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php