php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73955 array_search returns null
Submitted: 2017-01-18 09:38 UTC Modified: 2017-01-18 09:41 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: 171933346 at qq dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.6.29 OS: mac
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: 171933346 at qq dot com
New email:
PHP Version: OS:

 

 [2017-01-18 09:38 UTC] 171933346 at qq dot com
Description:
------------
array_search($value,$arr);

the returns of this function is not expected。it displays false or the key from doc. but I get false、null、key。

php -version : 5.6.10

Test script:
---------------
$arr = null;
$key = array_search(2, $arr);
if( $key === false)
   echo 'no value';
else
   echo 'the key is '.$key;


Patches

Idontknowthepatchname.php (last revision 2017-01-18 09:40 UTC by 171933346 at qq dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-18 09:41 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-01-18 09:41 UTC] requinix@php.net
Built-in functions typically return NULL when the arguments given are not of the correct types.
http://php.net/manual/en/functions.internal.php
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 22:00:01 2026 UTC