Usage of similar_text function in php: [similar_text(string1,string2,percent)]. The similar_text function is used to calculate the similarity of two strings and return the number of matching characters.
php The similar_text function is used to calculate the similarity of two strings and return the number of matching characters. Its syntax is similar_text(string1,string2,percent) .
(Recommended tutorial: php video tutorial)
How to use php similar_text function?
Function: Calculate the similarity of two strings and return the number of matching characters.
Syntax:
similar_text(string1,string2,percent)
Parameters:
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to be compared.
percent Optional. Specifies the variable name used to store percent similarity.
Explanation: The
function can also calculate the percentage similarity of two strings.
php similar_text() function usage example 1
<?php echo similar_text("Hello World","Hello php.cn"); ?>
Output:
6
php similar_text() function usage example 2
<?php echo similar_text("phpstudy","tomcat"); ?>
Output:
1
The above is the detailed content of How to use similar_text function in php. For more information, please follow other related articles on the PHP Chinese website!