Re: string vs number

From: Date: Wed, 06 Feb 2008 12:41:23 +0000
Subject: Re: string vs number
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-268769@lists.php.net to get a copy of this message
Ford, Mike schreef:
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
ah yes, I should have looked it up, that said I find it rather odd that is works let alone that it's intentional. though thinking about it you could probably use it for some float val distribution counting or something. I dunno, seems like it offers a handy shortcut - although what that shortcut is escapes me just now :-)
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


« previous php.general (#268769) next »