You need to explode()
your string and then implode()
it -
$myarray = 'zzz,aaa,bbb';
$realArray = explode(',', $myarray);
$stringForIn = "'" . implode("','", $realArray) . "'";
echo "WHERE ids IN ($stringForIn)";
I have a array like that :
$myarray= 'zzz,aaa,bbb' ;
and want use it in mysql IN clause like that :
"... WHERE ids IN ($myarray) " // didnt work
"... WHERE ids IN ('$myarray') " // didnt work
the error im getting is that the first value in that array zzz
says that zzz is not a column name . so i understand that i must separate the values with quotes to be like that :
$myarray= ' "zzz","aaa","bbb" ' ;
But i have no clue to do that . any help would be much appreciated.