#37235 [NEW]: in_array returns true for non-existing elements
| From: | hodacsi at mailbox dot hu | Date: | Fri, 28 Apr 2006 11:08:25 +0000 |
| Subject: | #37235 [NEW]: in_array returns true for non-existing elements | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-96319@lists.php.net to get a copy of this message | ||
From: hodacsi at mailbox dot hu
Operating system: Windows
PHP version: 5.1.2
PHP Bug Type: Arrays related
Bug description: in_array returns true for non-existing elements
Description:
------------
The code speaks for itself: in_array founds a string in the array when it
definitely should not.
The code is kept simple - I've also used variables and verified variable
types with gettype, so it's _should not_ be a matter of using strict
parameter.
Using the third 'strict' parameter it works as expected, even if it's
definitely not a question of types. Tested under several PHP versions and
platforms.
Reproduce code:
---------------
<?php
$ids = Array ( '+36901112222', 'xxxxx', 'zzzzz' );
echo in_array( ' 36901112222', $ids ) ? 'found' : 'not found';
?>
Expected result:
----------------
It should not find the string and should echo "not found".
Actual result:
--------------
"found"
--
Edit bug report at http://bugs.php.net/?id=37235&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37235&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37235&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37235&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37235&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37235&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37235&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37235&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37235&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37235&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37235&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37235&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37235&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37235&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37235&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37235&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37235&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37235&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37235&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37235&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37235&r=mysqlcfg