highlight the word in the string, if it contains the keyword
Posted
by Syom
on Stack Overflow
See other posts from Stack Overflow
or by Syom
Published on 2010-03-20T16:42:56Z
Indexed on
2010/03/20
16:51 UTC
Read the original article
Hit count: 380
php
how write the script, which menchion the whole word, if it contain the keyword? example: keyword "fun", string - the bird is funny, result - the bird is * funny*. i do the following
$str = "the bird is funny";
$keyword = "fun";
$str = preg_replace("/($keyword)/i","<b>$1</b>",$str);
but it menshions only keyword. the bird is *fun*ny
© Stack Overflow or respective owner