how can i search for 1 or 2 word match?
<?php
$a = key1, key2, key3;
$b = key3, key4, key5;
if (strpos($a,$b) != false) {
echo 'Great Is Found';
}
?>
this "strpos" returns result only if all sentence it's the same, what if I want even only 1 or 2 words match?
Try with array_intersect
, array_map
and explode
$a = "key1, key2, key3";
$b = "key3, key4, key5";
$intersect = array_intersect(array_map('trim',explode(",",$a)), array_map('trim',explode(",",$b)));
if ($intersect) {
echo 'Great Is Found';
var_dump($intersect);
}
After quick read it seems that you are looking for similar_text
or levenshtein
methods.