Curt Zirzow wrote: > To simplify things: > > $a[2] = '1'; > $k = (double)2; > echo isset($a[$k]); > unset($a[$k]); > echo isset($a[$k]); > echo " -> expect 1\n"; > > > Result: > 11 -> expect 1
Yeah, my version was just a wee bit verbose. :) >> It's the behavior that is specific to unset() that I'm puzzled about. >> > The problem is, array hash's and indexes must be either integer or > string as noted in the manual, so technically it really isn't a bug > even though it appears to behave like one. Yeah, I agree. Personally, IMHO if there is a problem the problem is with isset(), not unset(). IMHO isset($var[(double) 2]) should return false at the least. Ideally I think any attempt to use a double as an array index should produce a warning (or notice), just like trying to use a resource or object does ("Illegal offset type"). Although if the error didn't mention double specifically it'd probably confuse the heck out of people. > I would have to agree that there does seem to be inconsistencies > between isset and unset, So perhaps mabey submiting a Feature > Request showing how close php seems to supporting (floats) as indexes. Probably a good idea. > or to make the above not look too silly: > > $k = (int) ceil(3/4); That's what I ended up doing. I lost a couple of hours and quite a bit of hair first, though. :) Thanks for the feedback... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php