Way to get all alphabetic chars in an array in PHP?

$alphas = range('A', 'Z');

Documentation: https://www.php.net/manual/en/function.range.php


To get both upper and lower case merge the two ranges:

$alphas = array_merge(range('A', 'Z'), range('a', 'z'));

$alphabet = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');

Another way:

$c = 'A';
$chars = array($c);
while ($c < 'Z') $chars[] = ++$c;

PHP has already provided a function for such applications.
chr(x) returns the ascii character with integer index of x.
In some cases, this approach should prove most intuitive.
Refer http://www.asciitable.com/

$UPPERCASE_LETTERS = range(chr(65),chr(90));
$LOWERCASE_LETTERS = range(chr(97),chr(122));
$NUMBERS_ZERO_THROUGH_NINE = range(chr(48),chr(57));

$ALPHA_NUMERIC_CHARS = array_merge($UPPERCASE_LETTERS, $LOWERCASE_LETTERS, $NUMBERS_ZERO_THROUGH_NINE);