Skip to content

Instantly share code, notes, and snippets.

@adibenc
Created August 3, 2020 07:43
Show Gist options
  • Save adibenc/3ba8ed894899cf5753301e44625d3418 to your computer and use it in GitHub Desktop.
Save adibenc/3ba8ed894899cf5753301e44625d3418 to your computer and use it in GitHub Desktop.
cyclicAlpha
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