PHP/String/str word count
mixed str_word_count ( string str [, int count_type [, string char_list]] ) returns the number of words in a string
<?
$str = "This is a test, only a test, and nothing but a test.";
$a = str_word_count($str, 1);
$b = str_word_count($str, 2);
$c = str_word_count($str);
print_r($a);
print_r($b);
echo "There are $c words in the string\n";
?>
str_word_count-2.php
<?php
$summary = <<< summary
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
summary;
$words = str_word_count($summary,2);
$frequency = array_count_values($words);
print_r($frequency);
?>
str_word_count.php
<?php
$summary = <<< summary
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.
summary;
$words = str_word_count($summary);
echo "Total words in summary: $words";
?>