0;$n--) { $pos = strpos($numstr, $nums[$n]); if($pos > $tail) { $n++; break; } $tail = $pos; } echo $n; echo PHP_EOL;