3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LetterCounter { public static function CountLettersAsString(string $string) { $string = str_replace(" ", "", $string); $string = strtolower($string); $letters = str_split($string); foreach ($letters as $letter) { $lettersCount = array_filter($letters, function($key, $val) use ($letter) { var_dump($val); var_dump($key); var_dump($letter); return $val == $letter; }, ARRAY_FILTER_USE_BOTH); var_dump($lettersCount); } } } LetterCounter::CountLettersAsString("Test Gorilla");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/92IKa
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_STATIC_METHOD_CALL                                  'LetterCounter', 'CountLettersAsString'
          1        SEND_VAL                                                 'Test+Gorilla'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F92IKa%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/92IKa
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $key, !1 = $val, !2 = $letter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   14     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
   15     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   16     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   17    12        IS_EQUAL                                         ~6      !1, !2
         13      > RETURN                                                   ~6
   18    14*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F92IKa%3A13%240

Class LetterCounter:
Function countlettersasstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 29
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/92IKa
function name:  CountLettersAsString
number of ops:  31
compiled vars:  !0 = $string, !1 = $letters, !2 = $letter, !3 = $lettersCount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '+'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !0, $4
    7     7        INIT_FCALL                                               'strtolower'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !0, $6
    8    11        INIT_FCALL                                               'str_split'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !1, $8
   10    15      > FE_RESET_R                                       $10     !1, ->29
         16    > > FE_FETCH_R                                               $10, !2, ->29
   13    17    >   INIT_FCALL                                               'array_filter'
         18        SEND_VAR                                                 !1
         19        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F92IKa%3A13%240'
         20        BIND_LEXICAL                                             ~11, !2
   18    21        SEND_VAL                                                 ~11
         22        SEND_VAL                                                 1
         23        DO_ICALL                                         $12     
   13    24        ASSIGN                                                   !3, $12
   20    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                                 
   10    28      > JMP                                                      ->16
         29    >   FE_FREE                                                  $10
   23    30      > RETURN                                                   null

End of function countlettersasstring

End of class LetterCounter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.54 ms | 1405 KiB | 23 Q