echo all_overlap('9936КНМ-3К', '9932КНМ');
function all_overlap($s1, $s2)
{
if(!empty($s1) and !empty($s2))
{
echo '<strong>'.$s1.'<br>'.$s2.'</strong><br>';
$a1 = preg_split('//u', $s1, -1, PREG_SPLIT_NO_EMPTY);
$a2 = preg_split('//u', $s2, -1, PREG_SPLIT_NO_EMPTY);
//$a2 = str_split($s2);
$a = array();
foreach($a1 as $k1 => $v1)
{
$overlap = '';
$n = 0;
foreach($a2 as $v2)
{
//echo $v1.' = '.$v2.'<br>';
if($v1 == $v2 and mb_strlen($overlap) == 0 and $n == 0)
{
$overlap .= $v2;
$k1++; if(!empty($a1[$k1])){$v1 = $a1[$k1];}
}
elseif($v1 == $v2 and mb_strlen($overlap) == 0 and $n > 0)
{
$overlap .= $v2;
$k1++; if(!empty($a1[$k1])){$v1 = $a1[$k1];}
}
elseif($v1 == $v2 and mb_strlen($overlap) > 0 and $n > 0)
{
$overlap .= $v2;
$k1++; if(!empty($a1[$k1])){$v1 = $a1[$k1];}
}
elseif($v1 !== $v2 and mb_strlen($overlap) == 0 and $n == 0)
{
}
elseif($v1 !== $v2 and mb_strlen($overlap) == 0 and $n > 0)
{
}
elseif($v1 !== $v2 and mb_strlen($overlap) > 0 and $n > 0)
{
break;
}
$n++;
}
$c = mb_strlen($overlap);
if($c > 1)
{
//echo '==='.$overlap.'<br>';
$a[$c] = $overlap;
}
}
ksort($a);
//echo '<pre>'; print_r($a); echo'</pre>'; exit;
if(!empty(end($a)))
{
return end($a);
}
return '0';
}
else{
return 'No data';
}
}
$image = new Imagick($file.'.jpg');
$image->setCompressionQuality(100);
$image->thumbnailImage(600, 0);
$draw = new ImagickDraw();
$draw->setFillColor($color); // цвет текста
$draw->setFont($font); // шрифт
$draw->setFontSize(33); // размер шрифта
$draw->setGravity(Imagick::GRAVITY_CENTER);
$size = $image->queryFontMetrics($draw, $text);
$w = $size['textWidth'] + 55;
$h = $size['textHeight'] + 55;
$image->setCompressionQuality(100);
$image->thumbnailImage($w, 0);
$image->annotateImage($draw, 0, 0, 0, $text); // наложение текста
$image->thumbnailImage(600,0);
$image->writeImage($file.'_.jpg');
if(!empty($_POST['numberOfGame'] )){echo 'Если numberOfGame не пустой, то...';}