【问题标题】:append char to string in programatically looping in php在php中以编程方式循环将char附加到字符串
【发布时间】:2012-08-19 15:32:41
【问题描述】:

我在这里很困惑。

我怎样才能循环这个:

从0-9a-zA-Z开始

foreach 来自上述范围的字母数字字符,我必须创建一个字符串

第一个字符串将是

0000
... ( thousands of string generated between)
0009
... ( thousands of string generated between)
000a
... ( thousands of string generated between)
000z
000A
... ( thousands of string generated between)
000Z
.... ( thousands of string generated between)
ZZZA
... ( thousands of string generated between)
ZZZZ

【问题讨论】:

    标签: php string loops char append


    【解决方案1】:

    这是一种解决方案:

    $corpus = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    for( $i = 0; $i < strlen($corpus); $i++ )
       for( $j = 0; $j < strlen($corpus); $j++ )
          for( $k = 0; $k < strlen($corpus); $k++ )
             for( $l = 0; $l < strlen($corpus); $l++ )
                  print substr($corpus, $i, 1).substr($corpus, $j, 1).substr($corpus, $k, 1).substr($corpus, $l, 1)."\n";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-20
      • 2013-04-09
      • 1970-01-01
      • 1970-01-01
      • 2017-03-19
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多