ID: 30000
User updated by: rcnetto at yahoo dot com
Reported By: rcnetto at yahoo dot com
Status: Wont fix
Bug Type: Arrays related
Operating System: Linux - Suse 9.1
PHP Version: 5.0.1
New Comment:
Interesting,... using the strict parameter will force in_array to check
types (or not converting to int??). Then the result will be ok.
Previous Comments:
------------------------------------------------------------------------
[2004-10-06 01:57:08] [EMAIL PROTECTED]
Numeric strings get converted to integers when used as array keys.
Because ints are limited to 32 bits (on x86) they end up being 0 on
very large numbers.
------------------------------------------------------------------------
[2004-09-06 17:02:15] rcnetto at yahoo dot com
Description:
------------
I tried to check if a value existed in an array, but in_array did not
return what I expected when I'm dealing with large strings (18 chars or
longer).
I have PHP 5.0.1 compiled with Apache 2.0.50 and DBG v2.11.26 running;
Reproduce code:
---------------
<?php
$needle = '123456789012345671';
$arrayA = array('123456789012345672'); // check number is
different
var_dump(in_array($needle, $arrayA)); // the correct output is
FALSE, but TRUE is printed
?>
Expected result:
----------------
bool(false)
OBS: $needle does not exists in $arrayA (last number is different),
that's why it should return FALSE.
Actual result:
--------------
bool(true)
Notes: when the value of the variables are letters, in_array works fine
with the same quantity of chars.
i.e:
<?php
$needle = 'abcdefghijklmnopqr1';
$arrayA = array('abcdefghijklmnopqr2'); // last char is different
var_dump(in_array($needle, $arrayA));
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30000&edit=1