$string = "Lorem Ipsum is #simply# dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard #dummy# text ever since the 1500s, when an unknown printer took a galley of #type1# and scrambled it to #make# a #type2# specimen book. It has survived not only #five# centuries, but also the #leap# into electronic typesetting, remaining essentially unchanged";
I have set of hard code words like "#simply# | #dummy# | #five# | #type1#"
What I expect as a output is:
If hard code words is found in
$stringit should get highlighted in black. like"<strong>...</strong>".If a word in
$stringis within#...#but not available in the hard code word list then those words in the string should get highlighted in red.please note that even though we have #type1# in hard code words, if $string contains
#type2#or#type3#it should also get highlighted .
for doing this I have tried as below
$pattern = "/#(\w+)#/";
$replacement = '<strong>$1</strong>';
$new_string = preg_replace($pattern, $replacement, $string);
This gets me all the words which are within #..# tags highlighted.
I'm bad in preg_ can someone help. thanks in advance.