regex to higlight the word part-by-part if it contain the keyword

Le_Baron

New Member
i've asked same question before here, but now i need to higlight the keywortd in another way, then other part of word. example will be helpful i think\[code\]$str = "i like programming very much";$key = "gram"; \[/code\]i need to get something like pro gram ming\[code\]$str = "i like <span class='first'>pro</span><span class='second'>gram</span><span class='firs'>ing</span>"why preg_replace("/([^\s]*?)(".preg_quote($key).")([^\s]*)/iu","<span class="first">$0</span><span class="second">$1</span><span class="first">$2</span>",$str);doesn't work?\[/code\]Thanks
 
Back
Top