PHP Case Insensitive Word Replacement
        Posted  
        
            by zuk1
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by zuk1
        
        
        
        Published on 2010-06-17T22:20:01Z
        Indexed on 
            2010/06/17
            22:23 UTC
        
        
        Read the original article
        Hit count: 187
        
php
Ok I'm trying to make search terms bold in this search script I'm making, except I can't get it to work case insensitive.
    function highlight($term,$target){
    $terms = explode(" ", $term);
    foreach($terms as $term){
        $result = (eregi_replace($term, "<strong>$term</strong>", $target));
    }
    return $result;
}
That is the function I have so far.. It says on PHP.net that eregi_replace is case insensitive matching but it's obviously not working for some reason. (I'm a noob).
Any ideas? :D
© Stack Overflow or respective owner