Re: string vs number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx
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



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux