Definition
The similar_text() function calculates the similarity between two strings.
Syntax
similar_text(string1, string2, percent)
Parameters
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. |
Example
<?php
$str1 = "Hello World";
$str2 = "Welcome World";
echo similar_text($str1, $str2);
similar_text($str1, $str2, $percent);
echo $percent;