Jump to content

counting preg_match


gerkintrigg

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.