Case issue with eregi_replace in text highlight function

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

 



Hi all!

I have a text highlight function which does not behave exactly as
needed. Behavior is logical but result is cumbersome.

Instead of replacing the portion of the text with the same portion of
text with some highlighting code added before and after, it replaces the
said text with the chunk of text looked for (highlight), which is an
issue when there is a difference in case.

It is used in a product search engine and it is important to keep the
case the same.

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

Not very pritty.

How complicated would it be to prevent this from happening?

Thanks a lot in advance!

-- 
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