本文介绍了如何递归迭代字母表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要编写一个像这样遍历字母 (a-z) 的函数:
(这里是 a-c 的例子)
I need to write a function which iterates through alphabet (a-z) like this:
(here is an example for a-c)
a
b
c
aa
ab
ac
ba
bb
bc
ca
cb
cc
aaa
aab
aac
... and so on. (until the word has 5 characters)
知道怎么做吗?我想我需要一些递归函数.
any idea how to do this? I guess I need some recursive function.
推荐答案
无需递归!
for($char = 'a'; $char != 'aaaaaa'; $char++){
echo $char . PHP_EOL;
}
这篇关于如何递归迭代字母表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!