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

后端 未结 14 789
情话喂你
情话喂你 2020-12-22 20:44

Is there a way to get all alphabetic chars (A-Z) in an array in PHP so I can loop through them and display them?

14条回答
  •  不知归路
    2020-12-22 21:27

    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); 
    

提交回复
热议问题