Bug #16130 Updated: array_search does not return FALSE as documented
| From: | philip@php.net | Date: | Mon, 01 Apr 2002 04:53:57 +0000 |
| Subject: | Bug #16130 Updated: array_search does not return FALSE as documented | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-3713@lists.php.net to get a copy of this message | ||
ID: 16130
Updated by: philip@php.net
Reported By: mccarthy36@earthlink.net
Status: Assigned
Bug Type: Documentation problem
Operating System: Linux 2.4.12 / 2.4.17
PHP Version: 4.1.2
Assigned To: philip
New Comment:
This behavoir has now been documented, thank you for the report.
Previous Comments:
------------------------------------------------------------------------
[2002-03-18 02:27:56] derick@php.net
Works for me with 4.3.0-dev too.
Derick
------------------------------------------------------------------------
[2002-03-17 22:50:51] philip@php.net
This bug was fixed by Jeroen on Oct 5, 2001 as stated under bug #13567.
Assigning to self for a little more testing, this change took place in
4.2.0 and will be documented as such. Good thing in PHP everyone uses
== :))
<?php
$return = array_search('sorry', array('foo','bar'));
print '$return is type: '. gettype($return) ."\n";
if ($return === false) print "\$return === false\n";
if ($return === NULL) print "\$return === NULL\n";
/*
X-Powered-By: PHP/4.2.1-dev (3-17)
$return is type: boolean
$return === false
X-Powered-By: PHP/4.1.2
$return is type: NULL
$return === NULL
*/
?>
------------------------------------------------------------------------
[2002-03-17 21:08:16] mccarthy36@earthlink.net
I am calling array_search. I expect it to return FALSE if the needle
value is not in the haystack (as documented) -- it's not happening.
I searched the bug database and found this bug (#13567) reported for v.
4.0.5 and marked as closed, but the bug is still present in 4.1.2.
Script that demonstrates the problem:
$result = array_search( "M", array( "A", "Z" ) );
if ( $result === false ) {
echo "REALLY FALSE";
}
else {
echo "SOMETHING ELSE";
}
I expect the script to output "REALLY FALSE", instead it outputs
"SOMETHING ELSE".
Thanks.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16130&edit=1