Just noticed this today. The following script:
<quote>
$a = 2;
$b = ceil(3 / 2);
if ($a == $b) {
print "\$a and \$b are the same.\n";
}
$foo[$a] = '2';
if (isset($foo[$b])) {
print "\$foo[\$b] is set.\n";
}
unset($foo[$b]);
print_r($foo);
</quote>
Results in this output:
<quote>
$a and $b are the same.
$foo[$b] is set.
Array
(
[2] => 2
)
</quote>
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php