Hi Dado,
How about this:
$needle = "abc";
$haystack = "abcdacbasdasllaabc";
$len_string = strlen($haystack);
$j = 0;
for ($i=0;$i<$len_string;$i) {
if ($result = strpos($needle, $haystack, $i)) {
$res_array[$j] = $result;
$i = $result + 1;
$j++;
}
}
Explanation:
The for statement searches for the $needle as many times are there are characters in the $haystack. If the string is found (giving the position), the position is added to the $res_array as a numerated array. Also, the for statement variable, $i, is advanced (to prevent duplicated results) to the character after the position where the $needle was found. $j is incremented to increase the array number.
To find the number of successful occurances, use count($res_array).
Kind Regards,
~D.