3v4l.org

run code in 500+ PHP versions simultaneously
<?php function percentageSubStrings(array $inputs, array $needles): Generator { foreach($inputs as $input) yield [$input => ((count($words = explode(' ', $input)) - count(array_diff($words, array_filter($needles, fn($x) => in_array($x, $words))))) / count($needles)) * 100]; } var_dump(iterator_to_array(percentageSubStrings(['Some short text', 'Some much longer text'], ['Some', 'text', 'longer', 'much'])));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ASukY
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'iterator_to_array'
          2        INIT_FCALL                                                   'percentagesubstrings'
          3        SEND_VAL                                                     <array>
          4        SEND_VAL                                                     <array>
          5        DO_FCALL                                          0  $0      
          6        SEND_VAR                                                     $0
          7        DO_ICALL                                             $1      
          8        SEND_VAR                                                     $1
          9        DO_ICALL                                                     
         10      > RETURN                                                       1

Function percentagesubstrings:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 29
filename:       /in/ASukY
function name:  percentageSubStrings
number of ops:  31
compiled vars:  !0 = $inputs, !1 = $needles, !2 = $input, !3 = $words
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        GENERATOR_CREATE                                             
    5     3      > FE_RESET_R                                           $4      !0, ->29
          4    > > FE_FETCH_R                                                   $4, !2, ->29
    6     5    >   INIT_FCALL                                                   'explode'
          6        SEND_VAL                                                     '+'
          7        SEND_VAR                                                     !2
          8        DO_ICALL                                             $5      
          9        ASSIGN                                               ~6      !3, $5
         10        COUNT                                                ~7      ~6
         11        INIT_FCALL                                                   'array_diff'
         12        SEND_VAR                                                     !3
         13        INIT_FCALL                                                   'array_filter'
         14        SEND_VAR                                                     !1
         15        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
         16        BIND_LEXICAL                                                 ~8, !3
         17        SEND_VAL                                                     ~8
         18        DO_ICALL                                             $9      
         19        SEND_VAR                                                     $9
         20        DO_ICALL                                             $10     
         21        COUNT                                                ~11     $10
         22        SUB                                                  ~12     ~7, ~11
         23        COUNT                                                ~13     !1
         24        DIV                                                  ~14     ~12, ~13
         25        MUL                                                  ~15     ~14, 100
         26        INIT_ARRAY                                           ~16     ~15, !2
         27        YIELD                                                        ~16
    5    28      > JMP                                                          ->4
         29    >   FE_FREE                                                      $4
    7    30      > GENERATOR_RETURN                                             


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ASukY
function name:  {closure:percentageSubStrings():6}
number of ops:  5
compiled vars:  !0 = $x, !1 = $words
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        FRAMELESS_ICALL_2                in_array            ~2      !0, !1
          3      > RETURN                                                       ~2
          4*     > RETURN                                                       null

End of Dynamic Function 0

End of function percentagesubstrings

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
177.34 ms | 2087 KiB | 21 Q