Php compares similar strings. Php comparison of similar strings This article describes how php compares similar strings. Share it with you for your reference. The specific analysis is as follows: the similar_text function of php is used to compare similar string methods.
This article describes how php compares similar strings. Share it with you for your reference. The specific analysis is as follows:
The similar_text function of php is used to compare the similarity between two strings.
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$ Word2compare = "stupid "; $ Words = array ( 'Stupid ', 'Stu and pid ', 'Hello ', 'Foobar ', 'Stpid ', 'Upid ', 'Stuupid ', 'Sstuupiiid ', ); While (list ($ id, $ str) = each ($ words )){ Similar_text ($ str, $ word2compare, $ percent ); Print "Comparing '$ word2compare' with '$ str ':"; Print round ($ percent). "% \ n "; } /* Results: Comparing 'topid' with 'topid': 100% Comparing 'stupid 'with 'Stu and pid': 71% Comparing 'stupid 'with 'Hello': 0% Comparing 'stupid 'with 'foobar': 0% Comparing 'stupid 'with 'stpid': 91% Comparing 'stupid 'with 'upid': 80% Comparing 'stupid 'with 'stuupid': 86% Comparing 'stupid 'with 'sstuupiiid': 71% */ |
I hope this article will help you with php programming.
Examples in this article describes how php compares similar strings. Share it with you for your reference. The specific analysis is as follows: Here we use the similar_text function of php...