> so I'm taking that as double's are allowed, so the documentation
> need's to reflect that, since it currently says integers or strings
> are only allowed.
>
Sort of.....Strings and Integers *ARE* the only truly valid indices for
arrays. Other types are loosely allowed using some basic translation
criteria.
Doubles get converted to longs in a floor() style behavior:
i.e.: $a[1.1234] => $a[1], $a[980.829] => $a[980]
Booleans are converted to either 0 or 1:
i.e.: $a[false] => $a[0], $a[true] => $a[1]
Resources are translated to their resource ID number:
This is a little less obvious in its meaning. For example, if I $fp =
fopen('foo.txt', 'r') it'll return a resource, if you var_dump($fp) that
resource you might see something like: Resource #4 (stream). That "4" is
the unique identifier of the resource that the variable points to. What
this means for array indices is that: $a[$fp] => $a[4]
I don't particularly care for the behavior of resources, but *eh* whatcha
gonna do, it's probably there for BC reasons which go back to PHP3.
Apart from the above, only string and integer types are allowed which are
used untranslated:
$a[7] => $a[7]
$a['foo'] => $a['foo']
> And if so is this a php5 thing only or php4 also?
>
This particular translation bug existed in ZE1 (PHP4) as well. I MFH'd the
fix already.
-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php