Bug #18380: array_search does not allow needle of type of array
| From: | shelby at downloadfast dot com | Date: | Tue, 16 Jul 2002 23:05:10 +0000 |
| Subject: | Bug #18380: array_search does not allow needle of type of array | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-14351@lists.php.net to get a copy of this message | ||
From: shelby@downloadfast.com
Operating system: FreeBSD
PHP version: 4.1.2
PHP Bug Type: Arrays related
Bug description: array_search does not allow needle of type of array
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 bug report at http://bugs.php.net/?id=18380&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18380&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18380&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18380&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18380&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18380&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18380&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18380&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18380&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18380&r=globals