php - How do I display Excel-style cells from A to BJ? -
how display excel-style cells bj ?
<?php ($i = 'a'; $i <= 'bj'; $i++) { echo $i."<br>"; } ?>
only displays a
, b
. have stop @ bk
display till bj
. how work till zz
?
<?php ($i = 'a'; $i <= 'zz'; $i++) { if ($i == 'bk') break; echo $i."<br>"; } ?>
the problem using <=
.... because comparison alphabetic when you're comparing strings, , z
less za
, , c
> bj
... need use !==
comparison....
take end point
$endpoint = bj;
increment that
$endpoint++;
then do
for ($i = 'a'; $i !== $endpoint; $i++) { ... }
Comments
Post a Comment