Phpsimilar_text () function definition and usage, phpsimilar_text. Phpsimilar_text () function definition and usage. phpsimilar_textphpsimilar_text () function compute compares the similarity between two strings. This article introduces the phpsimilar_text () function base php similar_text () to the coders () function definition and usage, phpsimilar_text
The php similar_text () function is used to calculate and compare the similarity between two strings. This article introduces the basic usage and basic use examples of the php similar_text () function to the coders, for more information, see.
Definition and usage
The similar_text () function computes the similarity between two strings.
This function can also calculate the percentage similarity between two strings.
Note: The levenshtein () function is faster than the similar_text () function. However, the similar_text () function provides more accurate results with fewer necessary modifications.
Syntax
similar_text(string1,string2,percent)
Parameters |
Description |
String1 |
Required. Specifies the first string to be compared. |
String2 |
Required. Specifies the second string to be compared. |
Percent |
Optional. Specifies the name of the variable that stores the percentage similarity. |
Technical details
Return value: |
Returns the number of matching characters for two strings. |
PHP version: |
4 + |
Instance
Calculate the percentage similarity between two strings:
<?phpsimilar_text("Hello World","Hello Shanghai",$percent);echo $percent. "%";?>
The definition and usage of the above php similar_text () function is all the content shared by the editor. I hope you can give us a reference and support for the help house.
The definition and usage of http://www.bkjia.com/PHPjc/1125865.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1125865.htmlTechArticlephp similar_text () function, phpsimilar_text php similar_text () function to calculate and compare the similarity between two strings. This article introduces the basis of php similar_text () function to the coders...