gerkintrigg Posted December 1, 2009 Share Posted December 1, 2009 I'm sorry people... I just can't work this out. $pattern='~\b'.$word.'\b(?![^<]*?>)~'; $string="websites on the web are cobwebs"; if($r['flagged']=='y'){ $style='flagged'; $plus = count(preg_match($pattern, strip_tags($my_page))); $_SESSION['flagged']=$_SESSION['flagged']+$plus; } It's just counting massive numbers... I just want it to count instances of the word "web" but not "websites" or "cobwebs". I know I could use spaces to explode the sting but I have good reason for not doing that. Can anyone help me with this? Link to comment https://forums.phpfreaks.com/topic/183569-counting-preg_match/ Share on other sites More sharing options...
salathe Posted December 1, 2009 Share Posted December 1, 2009 Neil, your other threads on this topic provide answers (or the best answer we can give based on your input). Please take the time to go back over them. If you're still stuck, please reply there with specific comments on what is/is not working, rather than create dozens of new threads. Link to comment https://forums.phpfreaks.com/topic/183569-counting-preg_match/#findComment-968898 Share on other sites More sharing options...
gerkintrigg Posted December 1, 2009 Author Share Posted December 1, 2009 I will do that then, but I would like to point out that each new thread I've posted does contain different code and so I'm unsure whether your observation is a valid one... Link to comment https://forums.phpfreaks.com/topic/183569-counting-preg_match/#findComment-968901 Share on other sites More sharing options...
salathe Posted December 1, 2009 Share Posted December 1, 2009 The code may be different but the problem is always the same: counting (or matching) words in a string. Thank you for updating one of the other threads with where you are at now. Link to comment https://forums.phpfreaks.com/topic/183569-counting-preg_match/#findComment-968932 Share on other sites More sharing options...
gerkintrigg Posted December 1, 2009 Author Share Posted December 1, 2009 okay, thanks for the clarification. Link to comment https://forums.phpfreaks.com/topic/183569-counting-preg_match/#findComment-968933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.