I have a list of many strings that have similarities, example :
$str = array('monkey eat a banana',
'dog eat a banana',
'cat devour an apple',
'cat dine a coco'); //etc
I would like to extract X strings from this array that are the most different each other.
Example : if i want to extract 3 one, it will be : ‘monkey eat a banana’ and ‘cat dine a coco’ and ‘cat devour an apple’.
How can i implement this ? I have found the similar_text() function, i think i may use it but how to extract them with any value of X ?
thanks for your advices
ps : i use this for SEO, the goal is to avoid the most possible duplicate content.
2
Answers
Tested with the following example code, the conclusion is that: choose the strings with lowest
percentage
fromsimilar_text()
, they are the most different ones.The results is as follows:
$Hope to be helpful