Most of us asks whether it's possible to increment letters from the alphabet. Honestly, I thought that it was impossible to do so not until now. This article will discuss on how to display letters from A-Z or depending on the inputs set by user. We will use the range function to achieved this function.
So I have here a short php code on how to increment letters of the alphabet. I also provided an interface wherein you can set the starting letter and the ending letter.
So I have here a short php code on how to increment letters of the alphabet. I also provided an interface wherein you can set the starting letter and the ending letter.
Try Increment Letter in PHP here!
PHP Code
<?php
$range = range('A', 'Z');
foreach ($range as $char)
{
echo $char."<br>";
}
?>
Output
AB
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
X
Y
Z
If you want to set the starting letter and ending letter, you need to create variables such as $start and $end. replace the code range('A', 'Z') with range($start,$end). But don't forget to define the values for your $start and $end. Let's say $start='D' and $end='O'. It will display letters from D to O.
No comments:
Post a Comment