Home > Backend Development > PHP Tutorial > Definition and usage of php similar_text() function, phpsimilar_text_PHP tutorial

Definition and usage of php similar_text() function, phpsimilar_text_PHP tutorial

WBOY
Release: 2016-07-12 08:52:54
Original
892 people have browsed it

Definition and usage of php similar_text() function, phpsimilar_text

php similar_text() function calculates and compares the similarity of two strings. This article introduces php similar_text( ) function’s basic usage methods and basic usage examples, interested programmers can refer to it.

Definition and usage

The 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)
Copy after login

 

参数 描述
string1 必需。规定要比较的第一个字符串。
string2 必需。规定要比较的第二个字符串。
percent 可选。规定供存储百分比相似度的变量名。

technical details
返回值: 返回两个字符串的匹配字符的数目。
PHP 版本: 4

Example

Calculate the percentage similarity between two strings:

<&#63;phpsimilar_text("Hello World","Hello Shanghai",$percent);echo $percent. "%";&#63;>
Copy after login

The definition and usage of the php similar_text() function above are all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1125865.htmlTechArticleDefinition and usage of php similar_text() function, phpsimilar_text php similar_text() function calculates and compares the similarity of two strings Degree, this article introduces the basics of php similar_text() function to programmers...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template