Finding similarity in strings with similar_text
similar_text calculates the similarity between two strings implementing the World’s Best Algorithms by Oliver (ISBN 0-131-00413-1). Note that this implementation does not use a stack as in Oliver’s pseudo code, but recursive calls which may or may not speed up the whole process. Note also that the complexity of this algorithm is O(N**3) where N is the length of the longest string.
<?php $firstString = 'this world is very beautiful'; $secondString = 'this world is very beautiful and peoples are too good'; similar_text($firstString, $secondString, $percent); echo $percent . "<br>"; $secondString = 'are u crazy'; similar_text($firstString,$secondString, $percent); echo $percent; ?>