Puoi usare le esppressioni regolari.
Questa funzione l'ho scritta per trovare i match a partire da una certa posizione e per una certa lunghezza.

codice:
function zz_ereg($pattern, $string, &$offset, $len=-1)
{
  $len = ($len==-1?strlen($string)-$offset:$len);
  $substring = substr($string, $offset, $len);
  $result = ereg($pattern, $substring, $regs);
  if(!$result){
    return false;
  }
  else{
      $match = $regs[0];
      $offset += strpos($substring, $match); 
      return $match;      
  }
}
Guarda questo esempio


codice:
$string  = "Questo è un testo di prova per trovare 
            tutte le occorrenze della parola testo 
            in un testo";

$pattern = "testo";

for($count=0, $offset=0; 
    $match = zz_ereg($pattern, $string, $offset);
    $count++, $offset+=strlen($match));

echo "La parola 'testo' compare ".$count." volte";
Mi rendo conto che non è molto efficiente...cmq funziona!