Req #79583 [NEW]: Bug? in array_search

From: Date: Mon, 11 May 2020 06:14:45 +0000
Subject: Req #79583 [NEW]: Bug? in array_search
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226985@lists.php.net to get a copy of this message
From: yattyan83 at gmail dot com Operating system: Windows 64bit/Linux aa4240282e4d PHP version: 7.3.17 Package: Arrays related Bug Type: Feature/Change Request Bug description:Bug? in array_search Description: ------------ --- From manual page: https://php.net/function.array-search --- I used array_search() to look at the beginning of the array and find the location of the first null.(In order to fill the array's nulls per request) But array_search() tests 0 as null. Try the example below. Test script: --------------- $array = [ 'a' => 1, 'b' => 0, 'c' => null, 'd' => null ]; echo array_search(null, $array);//expect c > b Expected result: ---------------- I would have liked to have gotten a C back if I could. You can also use foreach as an alternative, so please let me know if this is a spec or a bug. -- Edit bug report at https://bugs.php.net/bug.php?id=79583&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79583&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79583&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79583&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79583&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79583&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79583&r=support Expected behavior: https://bugs.php.net/fix.php?id=79583&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79583&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79583&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79583&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79583&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79583&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79583&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79583&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79583&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79583&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79583&r=mysqlcfg

« previous php.bugs (#226985) next »