Trying to use a string of coma separated values compiled from a mysql query within an in_array() statement. The problem is that the statement fails because the output of $array does not work in the in_array() function even though the pasted output of array does work...
$quiz = mysql_query("SELECT id FROM quiz WHERE quiz_page = '2'");
$array1=array();
while($quiz2 = mysql_fetch_assoc($quiz))
{
$array1[]=$quiz2["id"];
}
$array = implode(",", $array1);
echo $array;
echo '<br>';
if (in_array(184, array($array))) {
echo '184 in $array';
} else {
echo '184 not in $array';
}
echo '<br>';
if (in_array(184, array(77,82,85,90,180,181,182,183,184,185))) {
echo '184 in array';
} else {
echo '184 not in array';
}
The result of the code above:
77,82,85,90,180,181,182,183,184,185
184 not in $array
184 in array