PHP - loop through letters

前端 未结 3 1581
广开言路
广开言路 2021-02-18 17:01

I am trying to loop through letters rather than numbers.

I am trying to do this using chr and the number equivalent but it doesn\'t seem to be happening!

I want

3条回答
  •  萌比男神i
    2021-02-18 17:13

    for( $x = "AAAA"; ; $x++) {
        echo $x."\n";
        if( $x == "ZZZZ") break;
    }
    

    Incrementing a letter will cycle it through the alphabet similar to the column names in Excel.

提交回复
热议问题