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

Posted by Toby A Inkster on 03/05/07 11:25

Geoff Berrow wrote:

> $file='foo.gif';
> echo substr($file, 0, strpos($file,".")); // echoes 'foo'

Assuming there is only one dot in the file name. (Which is often not a
safe assumption[1], but what the hell...)

list($name, $ext)=explode('.', $filename);

Much easier than faffing around with substr and strpos and all that junk.
____
1. http://message-id.net/ogt3b4-31g.ln1%40ophelia.g5n.co.uk

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

 

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

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