Re: [PHP] separating strings from extensions

2008-02-18 Thread Richard Lynch
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

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-18 Thread Richard Lynch
Since you provide the suffice (extension) to basename, it's not
basename that's broken...

It's not knowing what extension you wanted to provide in the first
place...

On Mon, February 18, 2008 11:56 am, Nick Stinemates wrote:
 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 ([EMAIL PROTECTED])
 http://nick.stinemates.org

 AIM: Nick Stinemates
 MSN: [EMAIL PROTECTED]
 Yahoo: [EMAIL PROTECTED]
 ==

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-18 Thread Nick Stinemates
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 ([EMAIL PROTECTED])
http://nick.stinemates.org

AIM: Nick Stinemates
MSN: [EMAIL PROTECTED]
Yahoo: [EMAIL PROTECTED]
==

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-18 Thread tedd

At 5:56 PM -0500 2/17/08, Daniel Brown wrote:

On Feb 17, 2008 5:37 PM, nihilism machine [EMAIL PROTECTED] 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)


You can STFW and RTFM.  This list should never be your first place
to ask simple questions.


Besides, it confuses us.

We think it's a trick question and have to think very hard about it. 
After realizing that it's a simple question, then we get all strange 
and stuff and start slobbering. Which in turn, shorts out our 
keyboards and we start typing all sorts of funny stuff. So, just 
don't do it.


It was bad enough that you used the variable named $extension and 
then asked what came before it, which is more a prefix type question 
-- see how confusing asking a simple question can become. So, just 
don't do it -- or did I already say that?


Cheers,

tedd (wiping off keyboard)

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-18 Thread Shawn McKenzie
Børge Holen wrote:
 On Monday 18 February 2008 00:10:30 John Meyer wrote:
 Daniel Brown wrote:
 On Feb 17, 2008 5:37 PM, nihilism machine [EMAIL PROTECTED] 
 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)
 You can STFW and RTFM.  This list should never be your first place
 to ask simple questions.

 In any case

 ?
 $split = explode('.',strtolower($fileName));
 $name = $split[0];
 $ext = $split[1];
 ?
 Flame job aside, that's going to fail on a compound extension such as
 .tar.gz by just returning .tar
 
 so.
 
 it.will.fail.this.one.to.txt 
 
 and a fix would also fail because you would have to hardcord everygoddamn 
 ending if thats what youre after. How many do you care to count for?
 I would say stick with the last dot, if its not particulary often you stumble 
 over those .tar.bz2 endings.
 
 what does he want to upload anyway?
 Oi you, whats yer task?
 
 
 
 
 
 
 

Regardless, a tar.gz file if it is gzipped is a gzip file.  You must
gunzip it to get the tar, just like manifesto.ps.tar is still a tar that
just happens to contain postscript files ;-)

-Shawn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-17 Thread Børge Holen
On Monday 18 February 2008 00:10:30 John Meyer wrote:
 Daniel Brown wrote:
  On Feb 17, 2008 5:37 PM, nihilism machine [EMAIL PROTECTED] 
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)
 
  You can STFW and RTFM.  This list should never be your first place
  to ask simple questions.
 
  In any case
 
  ?
  $split = explode('.',strtolower($fileName));
  $name = $split[0];
  $ext = $split[1];
  ?

 Flame job aside, that's going to fail on a compound extension such as
 .tar.gz by just returning .tar

so.

it.will.fail.this.one.to.txt 

and a fix would also fail because you would have to hardcord everygoddamn 
ending if thats what youre after. How many do you care to count for?
I would say stick with the last dot, if its not particulary often you stumble 
over those .tar.bz2 endings.

what does he want to upload anyway?
Oi you, whats yer task?







-- 
---
Børge Holen
http://www.arivene.net

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-17 Thread John Meyer

Daniel Brown wrote:

On Feb 17, 2008 5:37 PM, nihilism machine [EMAIL PROTECTED] 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)



You can STFW and RTFM.  This list should never be your first place
to ask simple questions.

In any case

?
$split = explode('.',strtolower($fileName));
$name = $split[0];
$ext = $split[1];
?

  



Flame job aside, that's going to fail on a compound extension such as 
.tar.gz by just returning .tar


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-17 Thread Daniel Brown
On Feb 17, 2008 5:37 PM, nihilism machine [EMAIL PROTECTED] 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)

You can STFW and RTFM.  This list should never be your first place
to ask simple questions.

In any case

?
$split = explode('.',strtolower($fileName));
$name = $split[0];
$ext = $split[1];
?

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-17 Thread John Meyer

Børge Holen wrote:

On Monday 18 February 2008 00:10:30 John Meyer wrote:
  

Daniel Brown wrote:

On Feb 17, 2008 5:37 PM, nihilism machine [EMAIL PROTECTED] 
  

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)


You can STFW and RTFM.  This list should never be your first place
to ask simple questions.

In any case

?
$split = explode('.',strtolower($fileName));
$name = $split[0];
$ext = $split[1];
?
  

Flame job aside, that's going to fail on a compound extension such as
.tar.gz by just returning .tar



so.

it.will.fail.this.one.to.txt 

and a fix would also fail because you would have to hardcord everygoddamn 
ending if thats what youre after. How many do you care to count for?
I would say stick with the last dot, if its not particulary often you stumble 
over those .tar.bz2 endings.
  



You could also stick with the first, i.e.:

?
$split = explode('.',strtolower($fileName),1);
$name = $split[0];
$ext = $split[1];
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-17 Thread Nick Stinemates
John Meyer wrote:
 Børge Holen wrote:
 On Monday 18 February 2008 00:10:30 John Meyer wrote:
  
 Daniel Brown wrote:

 On Feb 17, 2008 5:37 PM, nihilism machine
 [EMAIL PROTECTED]   
 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)
 
 You can STFW and RTFM.  This list should never be your first place
 to ask simple questions.

 In any case

 ?
 $split = explode('.',strtolower($fileName));
 $name = $split[0];
 $ext = $split[1];
 ?
   
 Flame job aside, that's going to fail on a compound extension such as
 .tar.gz by just returning .tar
 

 so.

 it.will.fail.this.one.to.txt
 and a fix would also fail because you would have to hardcord
 everygoddamn ending if thats what youre after. How many do you care
 to count for?
 I would say stick with the last dot, if its not particulary often you
 stumble over those .tar.bz2 endings.
   


 You could also stick with the first, i.e.:

 ?
 $split = explode('.',strtolower($fileName),1);
 $name = $split[0];
 $ext = $split[1];
 ?

Or you can stop spreading bad advice and listen to Brady Mitchell

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] separating strings from extensions

2008-02-17 Thread Brady Mitchell


On Feb 17, 2008, at 256PM, Daniel Brown wrote:

On Feb 17, 2008 5:37 PM, nihilism machine  
[EMAIL PROTECTED] 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)


   You can STFW and RTFM.  This list should never be your first place
to ask simple questions.


PLEASE start using the PHP manual!

http://php.net/pathinfo
http://php.net/basename

Brady

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php