php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40247 array_merge + array_search gives wrong result
Submitted: 2007-01-26 10:06 UTC Modified: 2007-01-26 10:14 UTC
From: y1ngf4n at hotmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.0 OS: Windows XP
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: y1ngf4n at hotmail dot com
New email:
PHP Version: OS:

 

 [2007-01-26 10:06 UTC] y1ngf4n at hotmail dot com
Description:
------------
seems like a very unique case,
since array_merge(range('a','z'),range('0','9')) will produce correct result

Reproduce code:
---------------
$test = array_merge(range('0','9'),range('a','z'));
var_dump(array_search('b',$test));

Expected result:
----------------
11

Actual result:
--------------
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-26 10:14 UTC] tony2001@php.net
(int)0 == (int)'b'
That's why the last argument of array_search() is there.

"If the optional third parameter strict is set to TRUE then the array_search() will also check the types of the needle in the haystack."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 00:01:34 2025 UTC