i want use foreach loop dynamically in php, i have task to print AAA to 999 and i'm using this code and it's work perfect,
Reference :: http://www.onlinecode.org/generate-string-aaaa-9999-using-php-code/
$addalphabeth = array_merge(range('A', 'Z'), range(0,9));
$setcharacter = [];
foreach ($addalphabeth as $setcharacter[0]) {
foreach ($addalphabeth as $setcharacter[1]) {
foreach ($addalphabeth as $setcharacter[2]) {
//$setcatalog[] = vsprintf('%s%s%s', $setcharacter);
echo "<b>".vsprintf('%s%s%s', $setcharacter)."</b>";
echo "<br>";
}
}
}
now my issue is have to print that AAAAA to 99999 (need loop 5 time) or AAAAAAAA to 99999999 (need loop 8 time) , so for this i use loop n time. I have no idea how to do it, any help or suggestion will be appreciated.
foreachandforloop withniterations.