i have an array of strings and i need to search whether the strings of the array exits in database or not. i am using following query:
foreach($array as $s)
{
if(preg_match('/^(\bpho)\w+\b$/', $s))
{
$query="select * from dictionary where words REGEXP '^".$s."$'";
$result=$db->query($query) or die($db->error);
if($result)
{
$count += $result->num_rows;
}
}
}
but this query taking long time to execute. PLease provide a solution to reduce the searching time
REGEXPwhen it looks like you're doing exact matches? Does$arraycontain regular expressions?$arraycontain things likepho\d*, i.e. are there regular expression operators in$array? Or are they just words likephonetic?preg_match, my question is why you're usingWHERE words REGEXP.