Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #15296
| From | "M. Strobel" <strobel@example.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: problem with double as array index? |
| Date | 2015-05-07 00:45 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <mie5fl$l1l$1@dont-email.me> (permalink) |
| References | <midt9v$ihf$1@dont-email.me> <Nsv2x.180740$an3.113965@fx23.fr7> |
On 06.05.2015 23:12, adam wrote: > On 2015-05-06, M. Strobel <strobel@example.com> wrote: >> I was not aware of this problem (not coding PHP for some time), what is it? > It is not a bug, it is a feature. :) > > Array key in PHP can either be an integer or a string. So when you use 0.5 it > gets auto-casted to an int which gives 0, so: > > array (0=>1, 0.5=>2, 1=>3) would be equivalent to array (0=>1, 0=>2, 1=>3) > > No magic here. > > http://php.net/manual/en/language.types.array.php > > Regards, > A. > Okay, got it, index can be an integer or a string, with automatic cast. You have to be an extremely good programmer to circumvent traps like this, so kudos to all PHP programmers writing stable and correct programs. /Str.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
problem with double as array index? "M. Strobel" <strobel@example.com> - 2015-05-06 22:25 +0200
Re: problem with double as array index? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-06 22:57 +0200
Re: problem with double as array index? adam <adam@nospam.net> - 2015-05-06 21:12 +0000
Re: problem with double as array index? "M. Strobel" <strobel@example.com> - 2015-05-07 00:45 +0200
Re: problem with double as array index? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-07 01:08 +0200
Re: problem with double as array index? "M. Strobel" <strobel@example.com> - 2015-05-07 13:36 +0200
csiph-web