Location: PHPKode > scripts > PHP Compare Strings > example.php
<?php
//$string1="This is my test string";
//$string2="no match";

//$string1="This is my test string";
//$string2="This is string";

$string1="This is my test string";
$string2="This is my text string";

require("phpCompareStrings.inc.php");
$phpCompareStrings=new PhpCompareStrings($string2, $string1);
$percent=$phpCompareStrings->getSimilarityPercentage();
$percent2=$phpCompareStrings->getDifferencePercentage();
echo '$string1 and $string2 are '.$percent.'% similar and '.$percent2.'% differnt';
?>
Return current item: PHP Compare Strings