How can i get select from the database with clause where = any values of array?

Hi i am trying to query from the database the query depends from values on an array but the query is not working is it possible to do it?

the model is a field on the database which i just want select the the models that i had on the array?

this is how i’ve tried how i tried

	<?php    
$cars=array("i10","i20","i30");
 		$sqlquery = "select * from cars where model = '".$cars."'";
		$result = mysql_query($sqlquery) or die(mysql_error());

while($row = mysql_fetch_array($result)){
	echo $row['model']. " - ". $row['total_cost'];
	echo "<br />";
}

?>

$cars=array("i10","i20","i30");
$sqlquery = "
    SELECT * 
    FROM cars 
    WHERE model IN ('" . implode("', '", $cars) . "')
";
$result = mysql_query($sqlquery) or die(mysql_error());

Thank you very much worked perfectly

hi i know is out the topic but is there a way of doing a str replace to look twice
like at moment i have if find space replace with

 .str_replace(' ','-',($row['model']))

is there a way i can do if find twice
$row['model
if find space " " replace with “-” also if find “i30” replace with “10”
is there a way i can try find another like if find " " replace with “-” also if find “130” replace with hello world??

thanks in advance

Yep, str_replace will take arrays as arguments


$replace_what = array(" ", "i30");
$replace_with = array("-", "10");

str_replace($replace_what, $replace_with, $row['model']);