#50135 [NEW]: array_search() false postive
| From: | nicolas dot vanlancker at gmail dot com | Date: | Tue, 10 Nov 2009 10:25:39 +0000 |
| Subject: | #50135 [NEW]: array_search() false postive | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-144408@lists.php.net to get a copy of this message | ||
From: nicolas dot vanlancker at gmail dot com
Operating system: Windows, Linux
PHP version: 5.2SVN-2009-11-10 (SVN)
PHP Bug Type: Arrays related
Bug description: array_search() false postive
Description:
------------
The specified code produces, at least as I see it, a false positive.
Needle and haystack values are of the same type and the matching value has
a different last character.
When I enforce the type test by setting the strict parameter to true,
the result is correct : Not found.
(I tested this on different PHP 4.X and 5.X installations on Windows and
Linux, all produce the same result)
Reproduce code:
---------------
$arr_ean=array('333333333333333333','541448820060826105','444444444444444444');
$pos=array_search('541448820060826106',$arr_ean);
if($pos===FALSE) {
echo "Not found";
} else {
echo "Found at key : $pos";
}
Expected result:
----------------
Not found
Actual result:
--------------
Found at key : 1
--
Edit bug report at http://bugs.php.net/?id=50135&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50135&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50135&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50135&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50135&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50135&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50135&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50135&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50135&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50135&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50135&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50135&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50135&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50135&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50135&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50135&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50135&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50135&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50135&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50135&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50135&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50135&r=mysqlcfg