String of the database in a matrix

advertisements

I have a field in my database which holds id's. An example would be: 1,2,3,4,5

I basically need to take that string and make it into 1 array so I can do a query with: WHERE id IN ($string_array).


PHP: explode - Manual

$string = "1,2,3,4,5";
$array = explode(",", $string);

$query = "SELECT * FROM `table` WHERE id IN (".$string.")";
$query = mysql_query($query);