|
Posted by Philip Hallstrom on 12/19/05 03:03
> hello again
> I am trying to figure out how i can read the list of files in a directory
> using the opendir() and readdir() functions. Normally this goes fine but
> within the loop, what i am wanting to do is echo the filename if it is a jpg
> file, but if its a .gif, just continue.
> I have several files i wish to seperate based on the basename of the file.
> i read the basename help file and know how to use it even to exclude the
> .3letterextention. I am however wanting to skip if it happens to be a .gif,
> is there some sort of way to i guess, do the basename function in reverse,
> e.g if it comes across "xxxxxx.gif" it would skip it but not skip over the
> xxx.jpg files?
> that is my latest problem, it skips everything when i have a line like this
> in my loop
>
> if($file = basename('.gif',$file))
> continue;
> else go on with code
>
if ( ereg("\.gif$", $file) ) {
continue;
}
would do it.. so would
if ( substr($file, -4) == ".gif" ) {
continue;
}
Don't forget about ".GIF" though if that might be an issue for you...
Navigation:
[Reply to this message]
|