Bug #39788 [Com]: in_array don't return false or true

From: Date: Mon, 07 Apr 2014 15:47:48 +0000
Subject: Bug #39788 [Com]: in_array don't return false or true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185134@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=39788&edit=1 ID: 39788 Comment by: kilbyc at bellsouth dot net Reported by: roberto at spadim dot com dot br Summary: in_array don't return false or true Status: Not a bug Type: Bug Package: Arrays related Operating System: ALL PHP Version: 5.2.0 Block user comment: N Private report: N New Comment: I am not entirely sure how this can be filed as "Not a Bug" Regardless of the emission of the Warning, the documentation clearly states that in_array returns bool, true, false. Null is not an acceptable value in that list. One of the two things needs to be fixed. Either update the manual to say that in_array throws a Warning, and returns NULL if the array is null. OR Fix the function to return false is the array is null. Previous Comments: ------------------------------------------------------------------------ [2006-12-10 14:09:03] tony2001@php.net PHP Warning: Wrong parameter count for in_array() in /tmp/6.php on line 25 Warning: Wrong parameter count for in_array() in /tmp/6.php on line 25 NULL ------------------------------------------------------------------------ [2006-12-10 13:26:10] roberto at spadim dot com dot br Description: ------------ RETURN NULL?!?! see documentation http://br.php.net/manual/pt_BR/function.in-array.php just can return TRUE or FALSE! NULL isn't allowed! see that i'm using 4 parameters and no error was showed Reproduce code: --------------- <?php $images=array( "cabec0" => "cabec0", "cabec1" => "cabec1", "cabec2" => "cabec2", "cabec3" => "cabec3", "cabec4" => "cabec4", "login0" => "login0", "login1" => "login1", "login2" => "login2", "login3" => "login3", "login4" => "login4", "messenger0" => "messenger0", "messenger1" => "messenger1", "messenger2" => "messenger2", "messenger3" => "messenger3", "messenger4" => "messenger4", "file_explorer0" => "explorer0","file_explorer1" => "explorer1", "file_explorer2" => "explorer2","file_explorer3" => "explorer3", "file_explorer4" => "explorer4", "yellow"=>"yellow","red"=>"red", "gray"=>"gray","blue"=>"blue","green"=>"green", "logo" => "logo.png", "smm" => "smm.gif" ); $image='rodape'; var_dump(in_array($image,'logo','rodape','smm')); print_r($images); ?> Expected result: ---------------- FALSE Actual result: -------------- NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=39788&edit=1

« previous php.bugs (#185134) next »