in_array() will always return true if a value in the haystack is of type bool(true).
This always hold except when the needle is of type bool(false).
Code:
<?php
$haystack = array(true);
$needle = "anything except bool(false)";
$result = in_array($needle, $haystack);
var_dump($result); #Will always be true
?>
Solution:
run in_array() with strict set to true.
<?php
in_array($needle, $haystack, true);
?>
Tested on PHP 5.2.6
----
Server IP: 69.147.83.197
Probable Submitter: 83.254.65.38
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/98043
Del: integrated -- https://master.php.net/note/delete/98043/integrated
Del: useless -- https://master.php.net/note/delete/98043/useless
Del: bad code -- https://master.php.net/note/delete/98043/bad+code
Del: spam -- https://master.php.net/note/delete/98043/spam
Del: non-english -- https://master.php.net/note/delete/98043/non-english
Del: in docs -- https://master.php.net/note/delete/98043/in+docs
Del: other reasons-- https://master.php.net/note/delete/98043
Reject -- https://master.php.net/note/reject/98043
Search -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.