Итак, если $term равен " круто" в результате preg_replace должно получиться:
Код: Выделить всё
My hair cut so cool!
Код: Выделить всё
0:
1: $term = 'cool';
2: ob_start();
3:
10: foreach($items as $item) {
11: // echoing results here
12: echo '' . $item->text . '';
13: }
30: $content = ob_get_contents();
31: ob_clean() ;
32:
33: $pattern = "/(?])($term)/i";
34: $replace = "$1";
35: echo preg_replace($pattern, $replace, $content);
36:
Подробнее здесь: https://stackoverflow.com/questions/292 ... -all-of-it
Мобильная версия