So I’m querying database, and it will return an array of id’s.
$val = $db->prepare("SELECT x FROM xx WHERE x_id='$xx'");
$val->execute();
$res = $val->fetchAll(PDO::FETCH_COLUMN, 0);
Then, I will separate the array with commas,
$x= join('', $res);
and echoing it would return 1,18,32.
Then I want to check if $_GET['id'] is one of these numbers
if($_GET['id] contains one of these){ // so here lies the problem, how do I check that it contains 1/18 or 32?
//continue...
}
else{
echo "You have no right to view this.";
}
But how?
Use
in_array(val, array).ref: http://php.net/manual/en/function.in-array.php