You are here: Re: separate file from its extension « PHP Programming Language « IT news, forums, messages
Re: separate file from its extension

Posted by Jerry Stuckle on 03/04/07 19:22

zorro wrote:
> On Mar 4, 3:25 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> Geoff Berrow wrote:
>>> Message-ID: <1173014480.065795.268...@30g2000cwc.googlegroups.com> from
>>> Davide contained the following:
>>>> $file = foo.gif
>>>> $file = strstr($file, ".");
>>>> it prints ".gif"
>>>> but I cannot print only the name of a file, "foo"
>>>> what function can do this?
>>> $file='foo.gif';
>>> echo substr($file, 0, strpos($file,".")); // echoes 'foo'
>> What about foo.bar.gif?
>
>
> $pathinfo = pathinfo('/what/ever/foo.bar.gif');
>
> echo str_replace('.'.$pathinfo['extension'], '',
> $pathinfo['basename']);
>
>
>

True - and much better if they have the possibility of a path in there
instead of just the file name.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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