PHP range() from A to ZZ?

后端 未结 12 1178
不思量自难忘°
不思量自难忘° 2020-11-30 06:52

Is it possible to get a range with PHP from A to ZZ*?

a b c ... aa ... zx zy zz

For me this didn\'t work:

range(\'A\', \'ZZ\');
12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 07:00

    You could ofcourse write your own function to do this as it seems that the range() function in php doesn't support this. This should be an easy job, since you can just nest the range function in another loop. Something like this:

    foreach(range('a', 'z') as $outer) {
      foreach(range('a', 'z') as $inner) {
        print($outer.$inner);
      }
    }
    

提交回复
热议问题