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);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 36
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 36
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/7OZ5d
function name:  (null)
number of ops:  41
compiled vars:  !0 = $sentences, !1 = $sentence, !2 = $letters, !3 = $out, !4 = $occurrences, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1      > FE_RESET_R                                       $7      !0, ->36
          2    > > FE_FETCH_R                                               $7, !1, ->36
   13     3    >   INIT_FCALL                                               'preg_match_all'
          4        SEND_VAL                                                 '%7E%5Ba-z%5Cd%5D%7E'
          5        INIT_FCALL                                               'strtolower'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $8      
          8        SEND_VAR                                                 $8
          9        SEND_REF                                                 !3
         10        DO_ICALL                                         $9      
         11      > JMPZ                                                     $9, ->15
         12    >   FETCH_DIM_R                                      ~10     !3, 0
         13        QM_ASSIGN                                        ~11     ~10
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~11     <array>
         16    >   ASSIGN                                                   !2, ~11
   14    17        INIT_FCALL                                               'array_count_values'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !4, $13
   15    21        INIT_FCALL                                               'arsort'
         22        SEND_REF                                                 !4
         23        DO_ICALL                                                 
   17    24        INIT_ARRAY                                       ~17     !1, 'sentence'
   18    25        INIT_FCALL                                               'key'
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                         $18     
         28        ADD_ARRAY_ELEMENT                                ~17     $18, 'character'
   19    29        INIT_FCALL                                               'current'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                         $19     
         32        ADD_ARRAY_ELEMENT                                ~17     $19, 'occurrences'
   16    33        ASSIGN_DIM                                               !5
   19    34        OP_DATA                                                  ~17
   12    35      > JMP                                                      ->2
         36    >   FE_FREE                                                  $7
   23    37        INIT_FCALL                                               'var_export'
         38        SEND_VAR                                                 !5
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.55 ms | 1404 KiB | 27 Q