From: mclaughlinm at byui dot edu Operating system: Windows PHP version: 5.4.15 Package: Arrays related Bug Type: Bug Bug description:in_array fails to find index
Description: ------------ --- >From manual page: http://www.php.net/function.in-array#refsect1-function.in-array-returnvalues --- Tested in 5.3 and 5.4 with the results that a numeric and string index aren't found in an array. Returns false when it should be true. There is no "Undefined index" error raised. Test script: --------------- testcase1.php ============= <?php $musketeers = array("Noble"=>"Athos","Priest"=>"Aramis" ,"Dandy"=>"Porthos","Hero"=>"d'Artagnan"); $search = "Dandy"; if (in_array($search,$musketeers)) print "[Is Found] [".$musketeers[$search]."]\n"; else print "[Not Found][".$musketeers[$search]."]\n"; ?> testcase2.php ============= <?php $musketeers = array("Athos","Aramis","Porthos","d'Artagnan"); $search = "2"; if (in_array($search,$musketeers)) print "[Is Found] [".$musketeers[$search]."]\n"; else print "[Not Found][".$musketeers[$search]."]\n"; ?> Expected result: ---------------- It should return true when finding the index value in the array. Actual result: -------------- Doesn't return true when finding the index value in the array, but doesn't raise an Undefined index error. -- Edit bug report at https://bugs.php.net/bug.php?id=64941&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64941&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64941&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64941&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64941&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64941&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64941&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64941&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64941&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64941&r=support Expected behavior: https://bugs.php.net/fix.php?id=64941&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64941&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64941&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64941&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64941&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64941&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64941&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64941&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64941&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64941&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64941&r=mysqlcfg