<?php
function alphabet_check( $str ){
$alphabets = [ 'Common', 'Arabic', 'Armenian', 'Bengali', 'Bopomofo', 'Braille', 'Buhid', 'Canadian_Aboriginal', 'Cherokee', 'Cyrillic', 'Devanagari', 'Ethiopic', 'Georgian', 'Greek', 'Gujarati', 'Gurmukhi', 'Han', 'Hangul', 'Hanunoo', 'Hebrew', 'Hiragana', 'Inherited', 'Kannada', 'Katakana', 'Khmer', 'Lao', 'Latin', 'Limbu', 'Malayalam', 'Mongolian', 'Myanmar', 'Ogham', 'Oriya', 'Runic', 'Sinhala', 'Syriac', 'Tagalog', 'Tagbanwa', 'TaiLe', 'Tamil', 'Telugu', 'Thaana', 'Thai', 'Tibetan', 'Yi' ];
$arr_str = mb_string_to_array ( $str );
foreach( $alphabets as $alphabet ){
foreach( $arr_str as $letter ){
$pattern = "#([\p{" . $alphabet . "}])+#simu"; #echo $pattern . "<hr>";
$arr_alpha[ $alphabet ] += preg_match( $pattern, $letter);
}
}
arsort( $arr_alpha );
return key($arr_alpha);
}
echo alphabet_check( "Ein Text mit Umlaute äÄüÜöÖ und ß" ); # Latin
Neuen Kommentar schreiben