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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 17:01:31 2024 UTC