Posted by Tyrone Slothrop on 10/02/05 05:19
On 1 Oct 2005 17:48:48 -0700, guttyguppy@gmail.com wrote:
>Newbie question:
>
>Is there any way to strip out the last four characters from the
>filenames when php does a readdir? If I run the following:
><?php
>if ($handle = opendir('.')) {
> while (false !== ($file = readdir($handle))) {
> if ($file != "." && $file != "..") {
> echo "$file\n";
> }
> }
> closedir($handle);
>}
>?>
>on a folder full of .jpg files, I want $file to not grab the .jpg
>extension. Hope that makes sense...
echo substr($file, 0, -4);
[Back to original message]
|