I need to find the number of times a needle appears in a haystack. Until this point I've put together the following code:
<?php
$haystack = 'http://www.google.com';
$needle = 'a';
$contents = file_get_contents($haystack);
?>
I want to find the number of times 'a' (the needle) appears in $contents (haystack - google.com's source code).
Thank you
substr_count
is what you are looking for.