I want to find number of similar words between two texts
Example
$str1=the cat is on the roof
$str2=the mouse is on the roof
the,is,on,the,roof words are similar in $str1 and $str2
So output will be in number 5 OR In percentage 86%
I am try similar_text() function but this function not work as which i want.
Easy, explode them and then use array_diff:
@Edit:
Edited code above to display percentage. However remember you may have a wrong result if the word count of array 1 and array 2 is not identical.
i used array_intesect to check how many matches,, i used this in searching one array into other
and for preventing with auxilary verbs and prepositions(the,to,a,are etc) use -
The way I would approach this is to explode each string and then use
array_diff
to compare them like this:That will echo out the number of similar words.