Hello can anyone spot why this fails to pick up the first and last keyphrases
Thanks in advance
<?
function exact_match($find, $data){
$find = explode("|",$find);
for($i=0;$i<sizeof($find); $i++){
if(preg_match("/\b".strtolower($find[$i])."\b/i", strtolower($data))){
return true;
}else{
return false;
}
}
}
$stringarray = array(
0 => "This string just contains ipod and no numbers",
1 => "This string contains the word ipod and the number 30 but not together",
2 => "This string contains the word ipod 30 but without GB",
3 => "This string contains the whole phrase ipod 30 GB",
4 => "This string contains another phrase we could use ipod 30GB",
5 => "This string also has another phrase we can use ipod white 30 gb",
6 => "This phrase has another too ipod (black) 30gb",
7 => "This phrase has another too ipod (white) 30gb"
);
$keyphrasearray = array(
0 => "ipod (black) 30gb",
1 => "ipod white 30 gb",
2 => "ipod 30gb",
3 => "ipod 30 gb",
4 => "ipod (white) 30gb"
);
for($i=0;$i<sizeof($stringarray);$i++){
for($ix=0;$ix<sizeof($keyphrasearray);$ix++){
if(exact_match($keyphrasearray[$ix], $stringarray[$i])){
echo $stringarray[$i]." Passed through!<br />";
}
}
}
?>