You are here: Re: [PHP] comparing two texts « PHP « IT news, forums, messages
Re: [PHP] comparing two texts

Posted by "Richard Lynch" on 06/18/05 23:42

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация