I am trying to use the php similar_text() function. I have some example code below. The 1st gives 100% as I hoped. The 2nd seems pretty reasonable also. But the third I would have expected 0% but get 26% even though none of the words are similar. Does anyone know why this is, how exactly does the similar_text() calculate this value?
Also if I wanted to round the 2nd and 3rd examples to zero decimal places can anyone tell me how I would write the code?
- Code: Select all
<?php
//Example 1
$text1 = "This is some text to be checked for plagerism";
$text2 = "This is some text to be checked for plagerism";
similar_text($text1, $text2, $similar);
print "These texts are $similar% similar";
print "<br /><br />";
//Example 2
$text1 = "This is some text to be checked for plagerism";
$text2 = "This is a sentence ready to be checked";
similar_text($text1, $text2, $similar);
print "These texts are $similar% similar";
print "<br /><br />";
//Example 3
$text1 = "This is some text to be checked for plagerism";
$text2 = "Nothing here relates with text1";
similar_text($text1, $text2, $similar);
print "These texts are $similar% similar";
print "<br /><br />";
?>
Thanks,
Andy ;-)


