|
|
|
|
for ($i='a';$i<='z';$i++) echo $i.' ';
|
| |
|
|
|
|
|
|
|
для: oliss
(30.06.2010 в 09:23)
| | . | |
|
|
|
|
|
|
|
для: oliss
(30.06.2010 в 09:23)
| | Если вопрос "почему не от a до z", то потому, что 'aa' < 'z', а 'z'++ равно 'aa'.
И если нужен алфавит, то нужно:
for ($i=ord('a');$i<=ord('z');$i++) echo chr($i) .' ';
|
| |
|
|
|
|
|
|
|
для: oliss
(30.06.2010 в 09:23)
| | http://ru2.php.net/manual/en/language.operators.increment.php :
-------------X cut X----------------
PHP follows Perl's convention when dealing with arithmetic operations on character variables and not C's.
For example, in Perl 'Z'+1 turns into 'AA', while in C 'Z'+1 turns into '[' ( ord('Z') == 90, ord('[') == 91 ).
Note that character variables can be incremented but not decremented and even so only plain ASCII characters (a-z and A-Z) are supported.
Example #1 Arithmetic Operations on Character Variables
<?php
$i = 'W';
for ($n=0; $n<6; $n++) {
echo ++$i . "\n";
}
?>
|
The above example will output:
Incrementing or decrementing booleans has no effect.
-------------X cut X---------------- | |
|
|
|