最后一点分,请教一个入门问题 我想用PHP列出所有的有26个字母组成的三字符,请问PHP该怎么写了? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $arr = explode(' ','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z');for ($i = 0; $i < 26; $i ++) { for($j = 0; $j < 26; $j ++) { for($k = 0; $k < 26; $k ++) echo $arr[$i].$arr[$j].$arr[$k]."<br />\n"; }} //想起来在PHP中可以直接使用[]来操作字符串,这样就不用把字符串转为数组了:$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';for ($i = 0; $i < 26; $i ++) { for($j = 0; $j < 26; $j ++) { for($k = 0; $k < 26; $k ++) echo $str[$i].$str[$j].$str[$k]."<br />\n"; }} 不用那么麻烦:$x="AAA";echo $x; while($x!="ZZZ")echo ++$x."\n"; 即可 再简化一下吧for($x="AAA";$x!="AAAA";$x++)echo $x."\n"; 这是我以前写的一个通用的获取最大组合的函数<?php$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';function getConstitutes($str, $size) { $max = strlen($str); for($i=$size; $i > -1; $i--) { $b[$i] = pow($max, $i); } $ret = array(); $count = 0; while($count < $b[$size]) { $constitute = ''; for($i= $size-1; $i > -1; $i--) { $constitute .= $count / $b[$i] % $max; } $ret[] = $constitute; $count++; } return $ret;}print_r(getConstitutes($str, 3)); 想不出比这个简单的了!for($x="AAA";$x!="AAAA";$x++)echo $x."\n"; 本机安装xampp 后的权限设置问题? 最后一点分,请教一个入门问题 【求助】该收指点,递归应用问题 关于PHP读取注册表的问题 apache php 的奇怪问题!!! js统计网站数据疑问 大家知道Discuz论坛吧?BBS用户的密码是什么加密算法呢?我想把论坛用户跟自己网站用户同步 天木兼职网源码数据库连接问题 php做SDK的数据统计和分析 phpcms的评论数为啥这样写不行呢 zendframework运行错误。 今天公司配置了台文件服务器 之前的上传的附件都需要移动文件服务器上去
for ($i = 0; $i < 26; $i ++) {
for($j = 0; $j < 26; $j ++) {
for($k = 0; $k < 26; $k ++) echo $arr[$i].$arr[$j].$arr[$k]."<br />\n";
}
}
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
for ($i = 0; $i < 26; $i ++) {
for($j = 0; $j < 26; $j ++) {
for($k = 0; $k < 26; $k ++) echo $str[$i].$str[$j].$str[$k]."<br />\n";
}
}
echo $x;
while($x!="ZZZ")echo ++$x."\n"; 即可
$max = strlen($str); for($i=$size; $i > -1; $i--) {
$b[$i] = pow($max, $i);
} $ret = array();
$count = 0;
while($count < $b[$size]) { $constitute = '';
for($i= $size-1; $i > -1; $i--) {
$constitute .= $count / $b[$i] % $max;
}
$ret[] = $constitute; $count++;
} return $ret;
}
print_r(getConstitutes($str, 3));
for($x="AAA";$x!="AAAA";$x++)echo $x."\n";