From: redeye at erisx dot de Operating system: * PHP version: 5.0.0 PHP Bug Type: Arrays related Bug description: array_search confusions
Description: ------------ When using array_search with strict set to FALSE will allways return the first matching element of an array, which is absolutly correct, but will also match every (boolean) TRUE value of an array (which is bad). This way, you could either hope no value is set to (boolean) TRUE or are forced to enable strict, which is not allways desired. This behavoir should either be better documented ( as is the behavior of FALSE ( "" , 0 , -1 , FALSE ) or changed to only match against ( "1" , 1 , "TRUE" , TRUE ). Reproduce code: --------------- $array = array ( 'foo' , TRUE , 'bar' ) ; $search = array_search ( 'baz' , $array ) ; var_dump ( $search ) ; Expected result: ---------------- bool(false) Actual result: -------------- int(1) -- Edit bug report at http://bugs.php.net/?id=29421&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29421&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29421&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29421&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29421&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29421&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29421&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29421&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29421&r=support Expected behavior: http://bugs.php.net/fix.php?id=29421&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29421&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29421&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29421&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29421&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29421&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29421&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29421&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29421&r=float