UrbanTwitch
09-01-2009, 02:48 AM
OK so I got this code and it only works when I put ONE word with NO space in it:
$text = "CodingForums are a great place to learn how to code. Also a good place to give help. CodingForums are blank!";
$text = preg_replace("/great/i", "<span style=\"background:yellow\">\\0</span>", $text);
echo $text;
OK, if I put great learn instead of great... then it won't highlight. However, if I just put great. It will highlight great. Is there a way to make it highlight words spaced apart?
$text = "CodingForums are a great place to learn how to code. Also a good place to give help. CodingForums are blank!";
$text = preg_replace("/great/i", "<span style=\"background:yellow\">\\0</span>", $text);
echo $text;
OK, if I put great learn instead of great... then it won't highlight. However, if I just put great. It will highlight great. Is there a way to make it highlight words spaced apart?