Bug #80505 [Opn->Nab]: BUG

From: Date: Fri, 11 Dec 2020 12:40:30 +0000
Subject: Bug #80505 [Opn->Nab]: BUG
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231014@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80505&edit=1 ID: 80505 Updated by: peehaa@php.net Reported by: juergen dot wilmsmann at juergenwilmsmann dot de Summary: BUG -Status: Open +Status: Not a bug Type: Bug Package: Unknown/Other Function PHP Version: 7.4.13 Block user comment: N Private report: N New Comment: For version < PHP 8 pass the strict argument to the function Previous Comments: ------------------------------------------------------------------------ [2020-12-11 12:38:02] juergen dot wilmsmann at juergenwilmsmann dot de Description: ------------ --- From manual page: https://php.net/function.array-search --- If in array integer 0 exists before the searched value exists, the search stopped by integer 0 and give as the result the key of integer 0. Test script: --------------- $arr[1] = "a"; $arr[2] = 0; $arr[3] = "c"; $arr[4] = "d"; $key = array_search("c", $arr); //Result is 2 - !!! Wrong !!! $arr[1] = "a"; $arr[2] = ""; $arr[3] = "c"; $arr[4] = "d"; $key = array_search("c", $arr); //Result is 3 - OK $arr[1] = "a"; $arr[2] = ""; $arr[3] = "c"; $arr[4] = 0; $key = array_search("c", $arr); //Result is 3 - OK ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80505&edit=1

« previous php.bugs (#231014) next »