php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #16130 array_search does not return FALSE as documented
Submitted: 2002-03-17 21:08 UTC Modified: 2002-04-01 12:40 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mccarthy36 at earthlink dot net Assigned: philip (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.1.2 OS: Linux 2.4.12 / 2.4.17
Private report: No CVE-ID: None
 [2002-03-17 21:08 UTC] mccarthy36 at earthlink dot 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-17 22:50 UTC] 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-18 02:27 UTC] derick@php.net
Works for me with 4.3.0-dev too.

Derick
 [2002-03-31 23:53 UTC] philip@php.net
This behavoir has now been documented, thank you for the report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 05:01:29 2024 UTC