DamienRoche Posted September 30, 2008 Share Posted September 30, 2008 Hi guys. I've just been looking into Geshi and how it functions..it's way too complicated for me right now but I have a question. Is there a simple way I can target every instance of a word in a string and style it? Any input much appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/126495-solved-php-pre-assigned-highlighting/ Share on other sites More sharing options...
DarkWater Posted September 30, 2008 Share Posted September 30, 2008 <?php $string = "There are some words in here, and I just so happen to like words. Isn't that great? I don't like it when words are inotherwords though. Aww."; $new_str = preg_replace('/\bwords\b/', '<span class="highlight">$0</span>', $string); echo $new_str; ?> Link to comment https://forums.phpfreaks.com/topic/126495-solved-php-pre-assigned-highlighting/#findComment-654090 Share on other sites More sharing options...
DamienRoche Posted September 30, 2008 Author Share Posted September 30, 2008 That is exactly what I was looking for. Thank you very much! Link to comment https://forums.phpfreaks.com/topic/126495-solved-php-pre-assigned-highlighting/#findComment-654105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.