Given an array of ids $galleries = array(1,2,5) I want to have a SQL query that uses the values of the array in its WHERE clause like:
$galleries = array(1,2,5)
As Flavius Stef's answer, you can use intval() to make sure all id are int values:
intval()
id
$ids = join(',', array_map('intval', $galleries)); $sql = "SELECT * FROM galleries WHERE id IN ($ids)";