RE: [PHP] string vs number
| From: | Ford, Mike | Date: | Wed, 06 Feb 2008 10:48:20 +0000 |
| Subject: | RE: [PHP] string vs number | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-268764@lists.php.net to get a copy of this message | ||
On 05 February 2008 21:37, Jochem Maas advised:
> the same is not exactly true for floats - although you can
> use them as array keys you'll
> notice in the output of code below that they are stripped of
> their decimal part (essentially
> a floor() seems to be performed on the float value. I have no
> idea whether this is intentional,
> and whether you can therefore rely on this behaviour:
Yes, and Yes!
From http://php.net/language.types.array:
> A key may be either an integer or a string. If a key is the
> standard representation of an integer, it will be interpreted
> as such (i.e. "8" will be interpreted as 8, while "08" will
> be interpreted as "08"). Floats in key are truncated to
> integer.
--
Mike Ford, Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 812 4730 Fax: +44 113 812 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm