php similar_text

WBOY
Release: 2016-07-29 08:49:32
Original
1114 people have browsed it

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.

Syntax

similar_text(string1,string2,percent)
Copy after login
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: Returns the number of matching characters in the two strings.
PHP version: 4+

Example

Calculate the percentage similarity between two strings:

<?<span>php
</span><span>similar_text</span>("Hello World","Hello Shanghai",<span>$percent</span><span>);
</span><span>echo</span><span>$percent</span>. "%"<span>;
</span>?>
Copy after login

Run online

Original address: http://www.manongjc .com/article/805.html

php related learning:

  • php operator
  • php expression
  • PHP loop control
  • PHP process control
  • php array
  • php function
  • php global variable
  • PHP magic variables
  • php namespace

The above introduces php similar_text, including similar and text content. I hope it will be helpful to friends who are interested in PHP tutorials.

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