Warning with highlighting ...
I used :
<?php
$text = preg_replace('/('.$q.')/i','<span class=highlighting "">$1</span>' , $text);
?>
Because this line do not allow to highlight uppercase and lowercase correctly (transform uppercase to lowercase for exemple)
<?php
$text = str_ireplace( $q , '<span class=highlighting "">'.$q.'</span>', $text);
?>
But when $q contain some regex you have some problems ... for exemple :
<?php $q = '('; ?>
So you must use preg_replace to highlight correctly the text and you must create a function for escape bad regex caracters !
I think that a better function can be found but this works I guess :
<?php
function regex_escape( $q )
{
return preg_replace('/([\[\]\(\)\{\}\-\.\*\?\|\^\$])/', '\$1', $q);
}
?>