views:

33

answers:

1

I am experimenting with finding similar text between a string and an online article. I am playing with similar_text() in php that shows the percentage a string matches. But I am trying to figure out how to echo out what similar_text() is finding that is similar. Is there any way to do this?

Here is a sample of what I am trying to do:

$similarText = similar_text($articleContent, $wordArr[$wordNum][1], $p);


            //if(strpos($articleContent, $wordArr[$wordNum][1] ) !== false)
            if($p > .25)
            {

                $test =($wordArr[$wordNum][1] - similar_text($articleContent, $wordArr[$wordNum][1]));
                echo $test."<br/>";

                echo "Percent: $p%"."<br/>";
                echo "MATCH NAME<br/>";
                print_r($wordArr[$wordNum]);
                echo "<br/><br/>";


            }

The similar text gives me a percentage of the words that I am matching, but I kind of want to see how it is working, and actually show the word it matches to the word it is matching. Like echo out:

echo $matcher." matches ".$matchee
A: 

Consider make a example for get a better answer.

<?
similar_text($string1, $string2, $p);
echo "Percent: $p%";
?> 

If you need see how much characters have been changed.

<?=(strlen($string2) - similar_text($string,$string2));?>
shakaran
ok this helped a little, but stil not quite what I need. I need a little more detail. I put some code samples above. Maybe there is a better way to do this.
pfunc