<?php
function check($input, $length = 4)
{
$sequence = "abcdefghijklmnopqrstuvwxyz";
$sequence .= substr($sequence, 0, $length - 1);
// abcdefghijklmnopqrstuvwxyz is converted to abcdefghijklmnopqrstuvwxyzabc
for ($i = 0; $i < strlen($sequence) - $length; $i++) {
// loop runs for $i = 0...25
if (strpos($input, substr($sequence, $i, $length)) !== false) {
echo sprintf('"%s" contains "%s"' . "\n", $input, substr($sequence, $i, $length));
return true;
}
}
echo sprintf('"%s" is OK' . "\n", $input);
return false;
}
check("youlookgreatbcdetoday"); // "youlookgreatbcdetoday" contains "bcde"
check("youlookgreatklmtoday"); // "youlookgreatklmtoday" is OK
check("youlookgreattoday"); // "youlookgreattoday" is OK
check("youlookgreattodayza"); // "youlookgreattodayza" is OK
check("youlookgreattodayzab"); // "youlookgreattodayzab" contains "yzab"
preferences:
40.27 ms | 402 KiB | 5 Q