From: Operating system: linux php PHP version: Irrelevant Package: *General Issues Bug Type: Feature/Change Request Bug description:0 is equal to false why not -1
Description: ------------ --- >From manual page: http://www.php.net/function.array-search%23Changelog --- array_search gives the result of false when nothing will be found , that is equal to index 0, why not -1. -1 means like in javascript , nothing is found. 0 would than be a correkt index found number. Test script: --------------- <?php $array = array(0 => 'blau', 1 => 'rot', 2 => 'grün', 3 => 'rot'); $key = array_search('grün', $array); // $key = 2; $key = array_search('rot', $array); // $key = 1; $key = array_search('yello', $array); // $key = 0; 0 is equal to false $key = isset( $array[$key] ) ? $key : -1 ; // this solve that 0/false to -1 ?> -- Edit bug report at https://bugs.php.net/bug.php?id=55229&edit=1 -- Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55229&r=trysnapshot52 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55229&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55229&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55229&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55229&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55229&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55229&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55229&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55229&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55229&r=support Expected behavior: https://bugs.php.net/fix.php?id=55229&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55229&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55229&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55229&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55229&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55229&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55229&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55229&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55229&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55229&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55229&r=mysqlcfg Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55229&r=trysnapshot54
