From:             rcnetto at yahoo dot com
Operating system: Linux - Suse 9.1
PHP version:      5.0.1
PHP Bug Type:     Arrays related
Bug description:  in_array returns the wrong result with long strings

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 bug report at http://bugs.php.net/?id=30000&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30000&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30000&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30000&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30000&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30000&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30000&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30000&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30000&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30000&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30000&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30000&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30000&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30000&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30000&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30000&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30000&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30000&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30000&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30000&r=mysqlcfg

Reply via email to