The title looks silly but many of us does not know the answer even experienced PHP developers struggle sometime!! Yes, it is true but printing all the alphabets from A to Z is very easy, once you have a glance at the code you will say “Oh my god I never knew this but it is pretty simple!”
Before going to the tutorial, I want to say if you know C Programming or if you remember which you have studied in college or school then this is going to surprise you!
Here is the script to print a to z:
1 2 3 4 5 6 7 8 9 |
<?php $alpharange = range( 'a', 'z' ); foreach ( $alpharange as $i ){ echo "$i\n"; } ?> |
the code is very simple, range() is a PHP function helps to create an array of elements within a range and in the above script we are fixing the range between a to z, then looping through each alphabets using foreach() function.
Pretty easy right?. Same as above you can also print A to Z just give the range like below:
1 2 3 4 5 6 7 |
<?php foreach (range('A', 'Z') as $i){ echo "$i\n"; } ?> |
Have Fun!
How to break loop condition
hiiii
how to print Z to A letters in php when we have two text box firstly. i write in first text box letter Z and second text box i write A then submit.
Hi I want to know how to write a php program using seven stars and place each star in a zig zag pattern??
The output should be 7-stars placed in zig-zag pattern
Hi very good information, may I know how can I add class to display letter as horizontal ways ?