Home  >  Article  >  Backend Development  >  How to use similar_text function in php

How to use similar_text function in php

藏色散人
藏色散人Original
2019-05-24 11:50:322258browse

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.

How to use similar_text function in php

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!

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