Friday 4 March 2011

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













01<?php










02$count = 0; // count start form zero










03$string = "bugphp -free online tutorials bugphp.com bugphp bugphp.com bugphpbugphp bugphp";










04










05foreach( str_word_count($string ,1) as $a ) {










06 if( strtolower($a) == strtolower('bugphp') )  {










07 $count++;










08 }










09}










10echo "$count";









11?>

No comments:

Post a Comment