<?php
$string = <<<_STRING_
Inky is pretty unlike any other email app currently available on Linux – not just in looks but also in features.
For example, Inky scans your inbox and contacts during set-up to work out which messages are more likely to be ‘important’ to you, and which aren’t. The darker an ink drop next to a message the more important Inky considers it.
_STRING_;
$word_count = str_word_count($string, 1);
$search_for = array('Inky', 'linux', 'email');
foreach ($search_for as $item) {
$count[$item] = 0;
}
foreach ($word_count as $key => $word) {
if (in_array($word, $search_for)) {
$count[$word]++;
}
}
print $count['Inky'];
print $count['linux'];
print $count['email'];
?>
只是一个粗略的例子,但希望它能让你走上正确的道路。