PHP 4.0 Bug #4753: in_array matches string vars as integers
| From: | patrick at spacesurfer dot com | Date: | Thu, 01 Jun 2000 10:38:09 +0000 |
| Subject: | PHP 4.0 Bug #4753: in_array matches string vars as integers | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-19948@lists.php.net to get a copy of this message | ||
From: patrick@spacesurfer.com
Operating system: linux 2.2
PHP version: 4.0 Release Candidate 1
PHP Bug Type: Misbehaving function
Bug description: in_array matches string vars as integers
I am running:
Apache/1.3.12 (Unix) mod_perl/1.21 PHP/4.0RC1 mod_ssl/2.6.2 OpenSSL/0.9.5
The problem is that in_array matches string vars as integer vars, for example the following code
will work incorrectly:
$a[0]="001";
$a[1]="003";
if (in_array("1", $a))
{
echo "As if<br>";
}
This is a big problem since it will cause the following code to produce an error:
$HAObjects["0011"]=$Object;
$HAObjects["0131"]=$Object;
if (in_array("11", array_keys($HAObjects)))
{
$O=$HAObject["11"];
$O->SomeFunction();
}