From: [EMAIL PROTECTED]
Operating system: Win 2K SP3
PHP version: 4.2.3
PHP Bug Type: Arrays related
Bug description: array_search(:object, :array) fails
array_search() does not seem to work when the needle is an object.
Sample code:
<?php
class A {
function A () {
}
}
class B {
function B () {
}
}
$g_b = new B ();
$g_array = array ( new A (), 'test', $g_b );
$g_key = array_search(new A (), $g_array);
var_dump($g_key);
$g_key = array_search($g_b, $g_array);
var_dump($g_key);
$g_key = array_search('test', $g_array);
var_dump($g_key);
?>
Output:
<br />
<b>Warning</b>: Wrong datatype for first argument in call to array_search
in <b>C:\dparks\Documents\html\tmp.php</b> on line <b>17</b><br />
bool(false)
<br />
<b>Warning</b>: Wrong datatype for first argument in call to array_search
in <b>C:\dparks\Documents\html\tmp.php</b> on line <b>20</b><br />
bool(false)
int(1)
Environment:
This is PHP 4.2.3 (binary from Zend or PHP.net) running on Apache 2.0.40
on Win 2K SP3.
Please email me if you would like me to run more tests, or try another
build (it may be awhile before I can try another build though -- someone
else here had trouble with 4.3rc1 and I am behind schedule).
Thanks,
Daniel
--
Edit bug report at http://bugs.php.net/?id=20681&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20681&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20681&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20681&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20681&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20681&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20681&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20681&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20681&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20681&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20681&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20681&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20681&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20681&r=isapi