Change your loop from
for ($c = 'A'; $c <= 'Z'; $c++) {
to
foreach (range('A', 'Z') as $c){
==============================
EDIT
Sorry, I tried to find an official document about this, but I can’t. Therefore, I will try to explain a little
In php, when you compare 2 lines, the system will try to compare the first character and then the second ..... the comparison operator will be stopped when the first different character appears
Example
$a = 'ABCDEZ';
$b = 'ABCEZZ';
String $b $a, ABC $a $b , E ( 3 $b) D ( 3 $a),
for ($c = 'A'; $c <= 'Z'; $c++) {
$c = 'Z', $++ "AA", php , "AA" < "Z" ,
foreach (range('A', 'Z') as $c){
, , , , , php,