php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18380 array_search does not allow needle of type of array
Submitted: 2002-07-16 19:05 UTC Modified: 2002-07-17 01:22 UTC
From: shelby at downloadfast dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.1.2 OS: FreeBSD
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: shelby at downloadfast dot com
New email:
PHP Version: OS:

 

 [2002-07-16 19:05 UTC] shelby at downloadfast dot com
Documention states:

array_search( mixed needle...

However:

$a = array( array( "test" ) );
echo array_search( array( "test" ), $a )

Outputs:

Warning: Wrong datatype for first argument in call to array_search 

Whereas:


foreach( $a as $key => $value )
{
	if( $value === array( "test" ) )
	{
		echo $key;
	}
}

Outputs:

0

Either the documentation is incorrect to state that needle is mixed type, or the function should be fixed to allow mixed input.  Preferably the latter.

Also in general, the array functions do not properly handle nested arrays.  For example, one can not array_diff() arrays that contain arrays.  Although this might be by design, it is a significant handicap (limitation) and the functions should be made more robust.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-17 01:22 UTC] sniper@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 14:01:32 2024 UTC