Ignore:
Timestamp:
Apr 1, 2004, 12:26:15 AM (21 years ago)
Author:
z0rglub
Message:

bug 23 : search case insensitive BUT highlightning case sensitive

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/release-1_3/include/functions.inc.php

    r274 r410  
    261261}
    262262
    263 // - add_style replaces the
    264 //         $search  into <span style="$style">$search</span>
    265 // in the given $string.
    266 // - The function does not replace characters in HTML tags
     263/**
     264 * replaces the $search into <span style="$style">$search</span> in the
     265 * given $string.
     266 *
     267 * case insensitive replacements, does not replace characters in HTML tags
     268 *
     269 * @param string $string
     270 * @param string $search
     271 * @param string $style
     272 * @return string
     273 */
    267274function add_style( $string, $search, $style )
    268275{
     
    278285  {
    279286    $treatment = substr ( $remaining, 0, $start );
    280     $treatment = str_replace( $search, '<span style="'.$style.'">'.
    281                               $search.'</span>', $treatment );
     287    $treatment = preg_replace( '/('.$search.')/i',
     288                               '<span style="'.$style.'">\\0</span>',
     289                               $treatment );
    282290    $return_string.= $treatment.substr( $remaining, $start, $end-$start+1 );
    283291    $remaining = substr ( $remaining, $end + 1, strlen( $remaining ) );
     
    285293    $end   = strpos ( $remaining, '>' );
    286294  }
    287   $treatment = str_replace( $search, '<span style="'.$style.'">'.
    288                             $search.'</span>', $remaining );
     295  $treatment = preg_replace( '/('.$search.')/i',
     296                             '<span style="'.$style.'">\\0</span>',
     297                             $remaining );
    289298  $return_string.= $treatment;
    290299               
Note: See TracChangeset for help on using the changeset viewer.