Home >Backend Development >PHP Tutorial >Detailed explanation of the definition and usage examples of similar_text() function in php

Detailed explanation of the definition and usage examples of similar_text() function in php

墨辰丷
墨辰丷Original
2018-06-02 11:40:591804browse

This article mainly introduces the definition and usage of similar_text() function in php. Interested friends can refer to it. I hope it will be helpful to everyone.

php similar_text() function calculates and compares the similarity of two strings. This article introduces the basic usage method and basic usage examples of php similar_text() function to coders. Interested coders can refer to it.

Definition and usage

similar_text() function calculates the similarity of two strings.

This function can also calculate the percentage similarity of two strings.

Note: levenshtein() function is faster than similar_text() function. However, the similar_text() function provides more accurate results with fewer modifications required.

Grammar

similar_text(string1,string2,percent)

 

Parameters Description
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.

Technical details

##Return value: Return two The number of matching characters in the string. PHP version: 4

##Example

Calculate the percentage similarity between two strings:

<?phpsimilar_text("Hello World","Hello Shanghai",$percent);echo $percent. "%";?>

Summary: The above is the entire content of this article, I hope it can be helpful to everyone’s learning help.

Related recommendations:

PHP method to access Alipay’s instant payment function


PHP database operation class based on pdo [Supports mysql, sqlserver and oracle]


php Detailed explanation of developing Alipay online payment interface

The above is the detailed content of Detailed explanation of the definition and usage examples of similar_text() function in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn