I have an array, array1 of words.
I want to return an array, array2 that contains all the words from array1 that do not exist in a given column (col1) of a given table (Table1).
What's the most efficient way of doing this?
Advice on checking an array against a database, please.
Moderator: General Moderators
Code: Select all
$array1 = array('some','words','here');
foreach($array1 as $key => $value)
$array1[$key] = mysql_escape_string($value);
$res = mysql_query('select word from sometable where word not in("' . implode('","', $array1) . '")');
while( list($word) = mysql_fetch_row($res) ) {
// do something to word
}