#49657 [Bgs]: array_search returns null instead of false
| From: | pvenakis at efrontlearning dot net | Date: | Fri, 25 Sep 2009 07:14:47 +0000 |
| Subject: | #49657 [Bgs]: array_search returns null instead of false | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-142849@lists.php.net to get a copy of this message | ||
ID: 49657
User updated by: pvenakis at efrontlearning dot net
Reported By: pvenakis at efrontlearning dot net
Status: Bogus
Bug Type: Unknown/Other Function
Operating System: windows
PHP Version: 5.3.0
New Comment:
Thanks for the quick response. It's fine that it returns null, but
since this changed from 5.2 to 5.3 it would be nice if it were mentioned
in the changelog or in the documents.
Best Regards, Periklis
Previous Comments:
------------------------------------------------------------------------
[2009-09-24 12:17:22] pajoye@php.net
That's expected. Returning NULL on invalid argument(s) is correct.
------------------------------------------------------------------------
[2009-09-24 12:03:47] pvenakis at efrontlearning dot net
Description:
------------
array_search returns false in 5.2.x, null in 5.3.0, when $haystack is
not an array
Reproduce code:
---------------
$haystack = false; //Anything not an array
$result = array_search(1, $haystack);
var_dump($result);
Expected result:
----------------
bool(false)
Actual result:
--------------
null
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49657&edit=1