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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
41 + 47 = ?
Subscribe to this entry?

 
 [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: Mon May 20 05:01:32 2024 UTC