RE: Case issue with eregi_replace in text highlight function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That's not where the issue is.

Eregi_replace conducts a case insensitive SEARCH but how the REPLACE
operates has nothing to do with it.

If you use ereg_replace, then it is most obviously not going to replace
"MacOS" with "<span class=highlight>macos</span>" or even "<span
class=highlight>MacOS</span>", because the string searched for is of a
different case.

But thanks for helping.

-----Original Message-----
From: Chris [mailto:dmagick@xxxxxxxxx] 
Sent: Wednesday, February 22, 2006 5:39 PM
To: Nicolas Verhaeghe
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  Case issue with eregi_replace in text highlight
function



> Here is the function:
> 
> function highlight_text($text, $highlight) {
> return eregi_replace($highlight, "<span class=highlight>" . $highlight

> . "</span>", $text); }
> 
> In this case, if the  text to highglight is:
> 
> MacOS X Super Gizmo
> 
> And a client searches for the string "macos", the result will be:
> 
> <span class=highlight>macos</span> X Super Gizmo

You're using the eregi_replace function - which does case insensitive 
replaces (read the man page).

Change it to use

ereg_replace

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux