Re: RE: Re: [PHP] pathinfo function

2011-07-27 Thread Tim Streater
On 27 Jul 2011 at 11:09, Mike Ford  wrote: 

>> -Original Message-
>> From: Tim Streater [mailto:t...@clothears.org.uk]

>> Seems to me that's the case. However the doc is ambiguous,
>> especially as I *asked* for that key to be returned. IMO it should
>> exist and be empty. Not existing is only OK if I didn't ask for it.
>
> This is how you tell the difference between a basename with a null
> extension ("/path/filename.") and no extension ("/path/filename").
> In the former case you get $info["extension"]=>"", in the latter
> there is no ["extension"] element in the returned array.

OK, this makes sense.

> This does seem like the most logical way to make this distinction,
> but the manual could use a bit of work to document this and other
> edge cases more explicitly.

I may have a go at this if I can find a round tuit.

--
Cheers  --  Tim

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

RE: Re: [PHP] pathinfo function

2011-07-27 Thread Ford, Mike
> -Original Message-
> From: Tim Streater [mailto:t...@clothears.org.uk]
> Sent: 27 July 2011 09:57
> 
> On 26 Jul 2011 at 23:55, Micky Hulse  wrote:
> 
> > On Tue, Jul 26, 2011 at 3:47 PM, Tim Streater
>  wrote:
> >> that I will get an error if I try to reference $info["extension"]
> ??
> >
> > From what I can tell via reading the docs:
> >
> > "The following associative array elements are returned: dirname,
> > basename, extension (if any), and filename."
> > 
> >
> > Makes me think that if the extension does not exist, then the
> > "extension" key will not exist.
> 
> Seems to me that's the case. However the doc is ambiguous,
> especially as I *asked* for that key to be returned. IMO it should
> exist and be empty. Not existing is only OK if I didn't ask for it.
> 

This is how you tell the difference between a basename with a null
extension ("/path/filename.") and no extension ("/path/filename").
In the former case you get $info["extension"]=>"", in the latter
there is no ["extension"] element in the returned array.

This does seem like the most logical way to make this distinction,
but the manual could use a bit of work to document this and other
edge cases more explicitly.

Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


Re: Re: [PHP] pathinfo function

2011-07-27 Thread Tim Streater
On 26 Jul 2011 at 23:55, Micky Hulse  wrote: 

> On Tue, Jul 26, 2011 at 3:47 PM, Tim Streater  wrote:
>> that I will get an error if I try to reference $info["extension"] ??
>
> From what I can tell via reading the docs:
>
> "The following associative array elements are returned: dirname,
> basename, extension (if any), and filename."
> 
>
> Makes me think that if the extension does not exist, then the
> "extension" key will not exist.

Seems to me that's the case. However the doc is ambiguous, especially as I 
*asked* for that key to be returned. IMO it should exist and be empty. Not 
existing is only OK if I didn't ask for it.


--
Cheers  --  Tim

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

Re: [PHP] pathinfo function

2011-07-26 Thread Micky Hulse
On Tue, Jul 26, 2011 at 3:47 PM, Tim Streater  wrote:
> that I will get an error if I try to reference $info["extension"] ??

>From what I can tell via reading the docs:

"The following associative array elements are returned: dirname,
basename, extension (if any), and filename."


Makes me think that if the extension does not exist, then the
"extension" key will not exist.

Looking like isset() (or array_key_exists) will be needed:

$foo = (isset($info['extension'])) ? $info['extension'] : '';

At least, that's my take on it. :)

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