Generate incremental id of numbers, Upper and Lower letters
This should work for you:
<?php
$hello = "aaa";
//'aaa0' -> 'aaa9'
for ($count = 0; $count <= 9; $count++)
echo $hello . $count . "<br />";
//'aaaa' -> 'aaaz'
foreach (range('a', 'z') as $char)
echo $hello . $char . "<br />";
//'aaaA' -> 'aaaZ'
foreach (range('A', 'Z') as $char)
echo $hello . $char . "<br />";
?>
EDIT:
This works only with 3 digit's. After you run out of memory for sure.
<?php
$array = array();
$maxLength = 3;
$output = array();
ini_set('memory_limit', '-1');
$time_start = microtime(true);
foreach(range(0, 9) as $number)
$array[] = $number;
foreach(range('a', 'z') as $char)
$array[] = $char;
foreach(range('A', 'Z') as $char)
$array[] = $char;
function everyCombination($array, $arrLength, $size, $perArr = array(), $pos = 0, &$found = array()) {
if ($size == $pos) {
$found[] = vsprintf("%s%s%s", $perArr);
return;
}
for ($count = 0; $count < $arrLength; $count++) {
$perArr[$pos] = $array[$count];
everyCombination($array, $arrLength, $size, $perArr, $pos+1, $found);
}
return $found;
}
$output = everyCombination($array, count($array), $maxLength);
for($count = 0; $count < count($output); $count++)
echo $output[$count] . "<br/>";
echo "DONE!";
$time_end = microtime(true);
$time = $time_end - $time_start;
echo round($time,2) . " s";
?>
Using 0,1-9, a-z and A-Z is "Base 62". Converting from base 10, to base 62 is very easy in PHP.
<?php
echo base_convert(10123, 10,26), "\n";
// outputs: 'ep9'
echo base_convert('ep9', 26, 10), "\n";
// output 10123