I would like to know how i can make something like this : Does a php function exists ?
for ($i=0; $i < 26; $i++) {
// echoes "A" ... b ... c ...
}
答案 0 :(得分:1)
PHP supports Perl-style character incrementing
so simply use
for($char = 'A'; $char !== 'IW'; $char++) {
echo $char, PHP_EOL;
}
which will print out from A
to IV
.... it is important to use a !==
in the terminating comparison though
答案 1 :(得分:1)
You can also use range()
foreach (range('a','z') as $char)
{
// do something with $char
}