Why doesn't this code simply print out the letters A to Z?
P粉239089443
P粉239089443 2024-01-21 15:39:33
0
2
544


<?php
for ($i = 'a'; $i <= 'z'; $i++)
    echo "$in";

This code snippet provides the following output (newlines replaced with spaces):

a b c def g h i j k l m no p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck cl cm cn co cp cq cr cs ct cu cv cw cx cy cz da db dc dd de df dg dh di dj dk dl dm dn do dp dq Dr ds dt du dv dw dx dy dze ea eb ec ed ee ef eg eh ei ej ek el em en eo ep eq er es et eu ev ew ex...to yz


P粉239089443
P粉239089443

reply all(2)
P粉555682718

Because once 'z' is reached (which is a valid result in the range, $i increments it to the next value in the sequence), the next value will be 'aa'; alphabetically, 'aa' is

for ($i = 'a'; $i != 'aa'; $i++) 
    echo "$i\n";
P粉308089080

From Documentation:

From comments: -
Also note that is a lexicographic comparison, so 'z' 1 ≤ 'z'. (Because 'z' 1 = 'aa' ≤ 'z'. But 'za' ≤ 'z' is false for the first comparison.) For example, $ i == 'z' will do.

Example.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template