function same_chars($first, $second)
{
$len = min(strlen($first), strlen($second));
$matched = 0;
for ($i = 0; $i < $len; ++$i) {
if ($first[$i] === $second[$i]) {
++$matched;
} else {
break;
}
}
return $matched;
}
var_dump(same_chars('9089102110', '90856')); // 3