Re: comparing two texts

From: Date: Sun, 19 Jun 2005 00:09:51 +0000
Subject: Re: comparing two texts
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-217189@lists.php.net to get a copy of this message
On Jun 18, 2005, at 3:42 PM, Richard Lynch wrote:
On Sat, June 18, 2005 3:21 am, jenny mathew said:
is it possible to compare two different text messages and highlight the difference in php. i mean to say that $text1="message 1" $text2="message 2" i want to compare both $text1 and $text2 for differences and highlight the differece in php.is it possible. waiting for your reply.
Untested, very crude: <?php $maxlen = max(strlen($text1), strlen($text2)); for ($i = 0; $i < $maxlen; $i++){
    if (@$text1[$i] == @$text2[$i]) echo @$text1[$i];
    else @echo "<font color=red>$text1[$i]|$text2[$i]</font>";
} ?> -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Would it be possible to explode both messages on " " into an array and run array_diff() and work from there? Just a thought late in the day... Edward Vermillion evermillion@doggydoo.net

« previous php.general (#217189) next »