3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * Задача: проверить, строка-предложение в переменной $pangram - это настоящая панграмма или нет? * (Правда ли включает в себя каждую букву данного алфавита $alphabet хотя бы 1 раз?) * * A Pangram (Greek: παν γράμμα, pan gramma, "every letter") or holoalphabetic sentence for a given * alphabet is a sentence using every letter of the alphabet at least once. * Source: wikipedia.org https://en.wikipedia.org/wiki/Pangram */ $alphabet = "abcdefghijklmnopqrstuvwxyz"; // English alphabet $alphabet_array = str_split(strtolower($alphabet)); $pangram = strtolower("Grumpy wizards make toxic brew for the evil Queen and Jack."); // English pangram $cnt = ''; $$cnt = 0; $array = array(); while(!empty($alphabet_array)){ $cnt = array_shift($alphabet_array); $$cnt = substr_count($pangram, $cnt); if($$cnt != 0){ $array["$cnt"] = $$cnt; }else{ echo "This is not a real pangram! $cnt is not found in this sentence."; exit; } } ksort($array); echo count($alphabet_array), count($array); foreach($array as $letter=>$occurrence){ echo "$letter was used " , ($occurrence==1)?"once \n":"$occurrence times \n"; }
based on 8vefS
Output for 5.6.0 - 7.3.0rc4
026a was used 4 times b was used once c was used 2 times d was used 2 times e was used 6 times f was used once g was used once h was used once i was used 3 times j was used once k was used 2 times l was used once m was used 2 times n was used 2 times o was used 2 times p was used once q was used once r was used 4 times s was used once t was used 2 times u was used 2 times v was used once w was used 2 times x was used once y was used once z was used once