SE non ho capito male cosa vuoi... dal manuale php

Codice PHP:
With reference to the google type searches above ...

This is a case insensitive replace....

This code below will highlight the "found" text in red and return the string unaltered (in terms of case).

<?php
function turn_red($haystack,$needle)
{
     
$h=strtoupper($haystack);
     
$n=strtoupper($needle);
     
$pos=strpos($h,$n);
     if (
$pos !== false)
         {
        
$var=substr($haystack,0,$pos)."<font color='red'>".substr($haystack,$pos,strlen($needle))."</font>";
        
$var.=substr($haystack,($pos+strlen($needle)));
        
$haystack=$var;
        }
     return 
$haystack;
}
?>