How to count how many times a certain word is used ,using php?

Posted: March 4, 2011 in PHP
Tags: , , ,
01 <?php
02 $count = 0; // count start form zero
03 $string = "bugphp -free online tutorials bugphp.com bugphp bugphp.com bugphpbugphp bugphp";
04
05 foreach( str_word_count($string ,1) as $a ) {
06 if( strtolower($a) == strtolower('bugphp') )  {
07 $count++;
08 }
09 }
10 echo "$count";
11 ?>
About these ads
Comments
  1. [...] How to count how many times a certain word is used ,using php? [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s