|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-02-08 08:22 UTC] giolaza at gmail dot com
[2019-02-08 09:32 UTC] spam2 at rhsoft dot net
[2019-02-08 09:33 UTC] sjon at hortensius dot net
[2019-02-08 09:34 UTC] giolaza at gmail dot com
-Status: Open
+Status: Closed
[2019-02-08 09:34 UTC] giolaza at gmail dot com
[2019-02-08 18:11 UTC] requinix@php.net
-Status: Closed
+Status: Not a bug
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 30 20:00:01 2025 UTC |
Description: ------------ in array return true if I am checking 0 var if $var=0; result is wrong int(0) in_array IS TRUE bool(true) $var=(int) 1-1; result is wrong; int(0) in_array IS TRUE bool(true) if $var=1; result is current int(1) in_array IS FALSE bool(false) if $var=NULL; result is current NULL in_array IS FALSE bool(false) if $var=''; result is current string(0) "" in_array IS FALSE bool(false) Test script: --------------- <?php $array=['users','documents','timePunch','vacation','requests']; $var=0; if(in_array($var,$array)){ echo 'in_array IS TRUE'; } else{ echo 'in_array IS FALSE'; } echo PHP_EOL; var_dump(in_array($var,$array)); Expected result: ---------------- in_array IS FALSE bool(false) Actual result: -------------- in_array IS TRUE bool(true)