Re: comparing two texts
| From: | M. Sokolewicz | Date: | Sun, 19 Jun 2005 16:33:13 +0000 |
| Subject: | Re: comparing two texts | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-217194@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
On Sun, 2005-06-19 at 09:22, M. Sokolewicz wrote:jenny mathew wrote:It's a bit of a dirty hack though. If I compare a 2 character text against a 40k text, the error handler will be invoked (39998 * 3) times if $text1 is the 2 byte string. That's extremely inefficient. I don't think I've ever seen error suppression abused so badly to prevent writing an extra line or 2 using isset(). Cheers, Rob. I agree with what you said fully; however, even though that's the case, and it indeed could be written a lot faster and cleaner, it would not pose a problem on most systems. That was the point I tried to make ;)40KB isn't large... now, when you're talking about hundreds of MBs of text, then it gets large :) 40KB, with that method, is nothing...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>"; } ?>donot you think you program will just bring the server to its foot ,if the text message encountered is very large of order of 40 KB or larger.is<http://larger.is>there any other efficient method.