You are here: Re: readdir and remove the .jpg extension from the file names « All PHP « IT news, forums, messages
Re: readdir and remove the .jpg extension from the file names

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);

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация