Home > Backend Development > PHP Tutorial > How to use similar_text function in php

How to use similar_text function in php

藏色散人
Release: 2023-04-06 19:30:02
Original
2353 people have browsed it

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

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");
?>
Copy after login

Output:

6
Copy after login

php similar_text() function usage example 2

<?php
echo similar_text("phpstudy","tomcat");
?>
Copy after login

Output:

1
Copy after login

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!

Related labels:
php
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