php - regex to also match accented characters -


i have following php code:

$search = "foo bar que"; $search_string = str_replace(" ", "|", $search);  $text = "this foo text qué , other accented characters."; $text = preg_replace("/$search_string/i", "<b>$0</b>", $text);  echo $text; 

obviously, "que" not match "qué". how can change that? there way make preg_replace ignore accents?

the characters have match (spanish):

á,Á,é,É,í,Í,ó,Ó,ú,Ú,ñ,Ñ 

i don't want replace accented characters before applying regex, because characters in text should stay same:

"this foo text qué , other accented characters."

and not

"this foo text que , other accented characters."

$search = str_replace(    ['a','e','i','o','u','ñ'],    ['[aá]','[eé]','[ií]','[oó]','[uú]','[nñ]'],    $search) 

this , same upper case complain request. side note: ñ replacemet sounds invalid me, 'niño' totaly diferent 'nino'


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -