Peter S.: suche in strings, inhalt ändern

hallo

habe ein webkatalog und würde gerne die such abfrage verbessern, das
wenn zb. einer nach "fun" sucht das wort "fun" fett zb. in der beschreibung angezeigt wird.
soweit so gut, habe hier auch schon tipps bekommen.
das prob. ist volgendes: wenn zb. einer nach "fun" sucht wird es auch fett angezeigt aber auch fett zb. im wort "funktion"
kann man irgendwie ändern, sollte aber gross/klein ignor...

hier mal ein auszug von der string fett routine:
$array = explode (" ", $searchtext); //suchtxt
      $text = $printit[description]; //beschreibung
      $total = count($array);
          $i = 0;
   while($i < $total){
  $foo = $array[$i];
   $bar = eregi_replace($foo, "<strong>$foo</strong>", $text);
      $text = $bar;
     $i++;
   }
             echo "$bar";

} else {
...

besten dank

  1. Hallo!

    hier mal ein auszug von der string fett routine:
    $array = explode (" ", $searchtext); //suchtxt
          $text = $printit[description]; //beschreibung
          $total = count($array);
              $i = 0;
       while($i < $total){
      $foo = $array[$i];
       $bar = eregi_replace($foo, "<strong>$foo</strong>", $text);
          $text = $bar;
         $i++;
       }
                 echo "$bar";

    } else {
    ...

    So geht das nicht (ohne weiteres), viel einfacher ist es mit http://php3.de/manual/de/function.preg-replace.php, mit \b definierst Du Wortgrenzen, also reicht folgender Ausdruck:

    $text_mit_strong = preg_replace("/\b($suchwort)\b/", "<strong>$1</strong>", $kompletter_text);

    Grüße
    Andreas