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.
Is this the fastest way to do this?
$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";