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

后端 未结 14 770
情话喂你
情话喂你 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:25

    Try this :

    function missingCharacter($list) {
    
            // Create an array with a range from array minimum to maximu
            $newArray = range(min($list), max($list));
    
            // Find those elements that are present in the $newArray but not in given $list
            return array_diff($newArray, $list);
        }
    print_r(missCharacter(array('a','b','d','g')));
    

提交回复
热议问题