php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80505 BUG
Submitted: 2020-12-11 12:38 UTC Modified: 2020-12-11 12:40 UTC
From: juergen dot wilmsmann at juergenwilmsmann dot de Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 7.4.13 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: juergen dot wilmsmann at juergenwilmsmann dot de
New email:
PHP Version: OS:

 

 [2020-12-11 12:38 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-11 12:40 UTC] peehaa@php.net
-Status: Open +Status: Not a bug
 [2020-12-11 12:40 UTC] peehaa@php.net
For version < PHP 8 pass the strict argument to the function
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 02:01:27 2024 UTC