Created
August 3, 2020 07:43
-
-
Save adibenc/3ba8ed894899cf5753301e44625d3418 to your computer and use it in GitHub Desktop.
cyclicAlpha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function cyclicAlpha($size,$n=0){ | |
$arr = range('A','Z'); | |
$gen = []; | |
$cnt = 0; | |
$strlen = 1; | |
for($i=$n;$i<=$size;$i++){ | |
if($cnt >= sizeof($arr)){ | |
$cnt=0; | |
} | |
// echo $strlen; | |
$addStr = ""; | |
if($strlen>1){ | |
$addStr.=$arr[$strlen-2]; | |
} | |
if(($i+1) % sizeof($arr) == 0){ | |
$strlen++; | |
} | |
$addStr .= $arr[$cnt]; | |
$gen[] = $addStr; | |
$cnt++; | |
$n++; | |
} | |
return $gen; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment