Infolinks

Breaking

Adsense

Friday, January 29, 2016

INCREMENT LETTER IN PHP: Display Letters From A to Z in PHP

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.

Try Increment Letter in PHP here!



PHP Code

<?php
$range = range('A', 'Z');
foreach ($range as $char)
{
echo $char."<br>";
}
?>

Output

A
B
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.

Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php and mysql here in my blog. Watch out for more upcoming tutorials related to blogging and programming. Good day! ^_^

INCREMENT LETTER IN PHP: Display Letters From A to Z in PHP

No comments:

Post a Comment

Adbox