Bug #18380 Updated: array_search does not allow needle of type of array

From: Date: Wed, 17 Jul 2002 05:22:37 +0000
Subject: Bug #18380 Updated: array_search does not allow needle of type of array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14366@lists.php.net to get a copy of this message
ID: 18380 Updated by: sniper@php.net Reported By: shelby@downloadfast.com -Status: Open +Status: Closed Bug Type: Arrays related Operating System: FreeBSD PHP Version: 4.1.2 New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2002-07-16 19:05:09] shelby@downloadfast.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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18380&edit=1

« previous php.bugs (#14366) next »