Re: Odd behavior with unset, array indexes, and types

From: Date: Thu, 17 Jun 2004 22:08:41 +0000
Subject: Re: Odd behavior with unset, array indexes, and types
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-188513@lists.php.net to get a copy of this message
On Thu, 17 Jun 2004 16:52:32 -0500, Michael Sims <michaels@crye-leike.com> wrote:
ceil() returns a variable of type double. In the above script I expected $foo to become an empty array after calling unset(). But it seems that unset() will not remove an array element when you refer to its key using a double, although isset() will return true when referenced the same way. If I cast $b to either an int or a string, the unset call works. Am I just missing the portion of the manual that documents this behavior, or is this a bug? Just thought I'd see if anyone had run across this before...TIA == does not check type in php. Hence, 2.0 == 2 == '2'. However, array indexes are type specific, so $a[2] != $a['2']. Use === for type specific checking, i.e.: echo 2 === '2'; will echo 0.
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

« previous php.general (#188513) next »