Counting php array occurrences in a string
<p>I have a string and an array of values, I want to check how many times the items in an array appear within a string.</p>

<p>Is this the fastest way to do this?</p>

<pre><code>$appearsCount = 0;

$string = "This is a string of text containing random abc def";
$items = array("abc", "def", "ghi", "etc");

foreach($items as $item)
{
    $appearsCount += substr_count($string, $item);
}

echo "The item appears $appearsCount times";
</code></pre>
