HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP String Reference : Calculate the similarity between two strings and return the matching characters
The similar_text() function calculates the similarity between two strings.
It can also calculate the similarity of the two strings in percent.
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to be compared |
string2 | Required. Specifies the second string to be compared |
percent | Optional. Specifies a variable name for storing the similarity in percent |
Return Value: | Returns the number of matching characters of two strings |
---|---|
PHP Version: | 4+ |
Calculate the similarity between two strings in percent:
<?php
similar_text("Hello World","Hello Peter",$percent);
echo $percent;
?>
❮ PHP String Reference