3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sentences = [ 0 => 'The tiger is the national animal of India', 1 => 'The tiger is a large carnivorous mammal that roams the forests', 2 => 'The tiger feeds on animals that also live in the forest', 3 => 'The tiger does have a coat of orange with black stripes', 4 => 'Tigers, regardless of their subspecies, are carnivorous animals', 5 => 'The tiger is a protected species', ]; foreach ($sentences as $sentence) { $letters = preg_match_all ('~[a-z\d]~', strtolower($sentence), $out) ? $out [0] : []; $occurrences = array_count_values($letters); arsort($occurrences); $result[] = [ "sentence" => $sentence, "character" => key($occurrences), "occurrences" => current($occurrences) ]; } var_export($result);

preferences:
60.35 ms | 402 KiB | 5 Q