Re: separating strings from extensions
| From: | Nick Stinemates | Date: | Mon, 18 Feb 2008 17:56:13 +0000 |
| Subject: | Re: separating strings from extensions | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269511@lists.php.net to get a copy of this message | ||
Richard Lynch wrote:
> On Sun, February 17, 2008 4:37 pm, nihilism machine wrote:
>
>> i am using this code to get the extension of a filename:
>>
>> $extension = strtolower(strrchr($fileName,"."));
>>
>> how can i get the text BEFORE the . (period)
>>
>
> http://php.net/basename
>
>
Funny enough, even in the comments someone states 'this breaks for
complex file-ending like .tar.gz'
Considering file names don't mean much, it would be OK (imo) to use
basename for standard operations. If you're working/looking for the
exact type, it's time to use MIME as it is more reliable than something
like a filename.
http://us2.php.net/manual/en/ref.mime-magic.php
Good luck.
==================
Nick Stinemates (nick@stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates@hotmail.com
Yahoo: nickstinemates@yahoo.com
==================