I need to print/list alphabetical(A-Z) chararcters to manage Excel cells. Is there any PHP function to list alphabetic?
I need result as
A1 B1 C1 D1 ... ...
OR
A B C ... ...
Is this possible?
All alphabetic characters in an array can be achieved by using chr(), range() with for and foreach loop in PHP. To display the array elements as output we can use echo, print_r() and var_dump() function.
php $upperArr = range('A', 'Z') ; $LowerArr = range('a', 'z') ; $myLetter = 't'; if(ctype_upper($myLetter)){ echo (array_search($myLetter, $upperArr) + 1); }else{ echo (array_search($myLetter, $LowerArr) + 1); } ?>
You can either do:
foreach (range('A', 'Z') as $char) { echo $char . "\n"; }
Or:
for ($char = 'A'; $char <= 'Z'; $char++) { echo $char . "\n"; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With