3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str="This is a test - That game is awesome (Cristiano Ronaldo is a great Soccer Player)"; //clean string: $str=preg_replace("/[^A-Za-z0-9 ]/", '', $str); //first explode it $e=explode(' ',$str); //loop to remove short words $out=array(); foreach ($e as $a){ if(strlen($a)>2){ $out[]=$a; } } $list = array( "This" => "9", "great" => "10", "God Father" => "11", "Tony Montana" => "12", "Ronaldo" => "13", "Al Pacino" => "14", "Humans" => "15", "Play" => "16" ); foreach ($out as $keyword) { foreach ($list as $word=>$num) { $sim_chars = similar_text($keyword, $word); if ($sim_chars/strlen($keyword) > .8 || $sim_chars/strlen($word) > .8) { $all_key_values[] = $num; $all_keys[] = $word; } elseif (stripos($keyword, $word) !== false || strpos($word, $keyword) !== false) { $sll_key_values[] = $num; $all_keys[] = $word; } } } print_r(implode(',', $all_key_values)); print_r(implode(',', $all_keys));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 20
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 67
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 67
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 65
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 65
Branch analysis from position: 27
2 jumps found. (Code = 47) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 47
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 47
2 jumps found. (Code = 47) Position 1 = 53, Position 2 = 59
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 64
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 64
Branch analysis from position: 59
Branch analysis from position: 41
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 65
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
Branch analysis from position: 21
filename:       /in/7avNv
function name:  (null)
number of ops:  83
compiled vars:  !0 = $str, !1 = $e, !2 = $out, !3 = $a, !4 = $list, !5 = $keyword, !6 = $num, !7 = $word, !8 = $sim_chars, !9 = $all_key_values, !10 = $all_keys, !11 = $sll_key_values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+is+a+test+-+That+game+is+awesome+%28Cristiano+Ronaldo+is+a+great+Soccer+Player%29'
    7     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5B%5EA-Za-z0-9+%5D%2F'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $13     
          6        ASSIGN                                                   !0, $13
   10     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '+'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $15     
         11        ASSIGN                                                   !1, $15
   13    12        ASSIGN                                                   !2, <array>
   14    13      > FE_RESET_R                                       $18     !1, ->21
         14    > > FE_FETCH_R                                               $18, !3, ->21
   16    15    >   STRLEN                                           ~19     !3
         16        IS_SMALLER                                               2, ~19
         17      > JMPZ                                                     ~20, ->20
   17    18    >   ASSIGN_DIM                                               !2
         19        OP_DATA                                                  !3
   14    20    > > JMP                                                      ->14
         21    >   FE_FREE                                                  $18
   22    22        ASSIGN                                                   !4, <array>
   34    23      > FE_RESET_R                                       $23     !2, ->67
         24    > > FE_FETCH_R                                               $23, !5, ->67
   35    25    > > FE_RESET_R                                       $24     !4, ->65
         26    > > FE_FETCH_R                                       ~25     $24, !6, ->65
         27    >   ASSIGN                                                   !7, ~25
   36    28        INIT_FCALL                                               'similar_text'
         29        SEND_VAR                                                 !5
         30        SEND_VAR                                                 !7
         31        DO_ICALL                                         $27     
         32        ASSIGN                                                   !8, $27
   37    33        STRLEN                                           ~29     !5
         34        DIV                                              ~30     !8, ~29
         35        IS_SMALLER                                       ~31     0.8, ~30
         36      > JMPNZ_EX                                         ~31     ~31, ->41
         37    >   STRLEN                                           ~32     !7
         38        DIV                                              ~33     !8, ~32
         39        IS_SMALLER                                       ~34     0.8, ~33
         40        BOOL                                             ~31     ~34
         41    > > JMPZ                                                     ~31, ->47
   38    42    >   ASSIGN_DIM                                               !9
         43        OP_DATA                                                  !6
   39    44        ASSIGN_DIM                                               !10
         45        OP_DATA                                                  !7
         46      > JMP                                                      ->64
   41    47    >   INIT_FCALL                                               'stripos'
         48        SEND_VAR                                                 !5
         49        SEND_VAR                                                 !7
         50        DO_ICALL                                         $37     
         51        TYPE_CHECK                                  1018  ~38     $37
         52      > JMPNZ_EX                                         ~38     ~38, ->59
         53    >   INIT_FCALL                                               'strpos'
         54        SEND_VAR                                                 !7
         55        SEND_VAR                                                 !5
         56        DO_ICALL                                         $39     
         57        TYPE_CHECK                                  1018  ~40     $39
         58        BOOL                                             ~38     ~40
         59    > > JMPZ                                                     ~38, ->64
   42    60    >   ASSIGN_DIM                                               !11
         61        OP_DATA                                                  !6
   43    62        ASSIGN_DIM                                               !10
         63        OP_DATA                                                  !7
   35    64    > > JMP                                                      ->26
         65    >   FE_FREE                                                  $24
   34    66      > JMP                                                      ->24
         67    >   FE_FREE                                                  $23
   48    68        INIT_FCALL                                               'print_r'
         69        INIT_FCALL                                               'implode'
         70        SEND_VAL                                                 '%2C'
         71        SEND_VAR                                                 !9
         72        DO_ICALL                                         $43     
         73        SEND_VAR                                                 $43
         74        DO_ICALL                                                 
   49    75        INIT_FCALL                                               'print_r'
         76        INIT_FCALL                                               'implode'
         77        SEND_VAL                                                 '%2C'
         78        SEND_VAR                                                 !10
         79        DO_ICALL                                         $45     
         80        SEND_VAR                                                 $45
         81        DO_ICALL                                                 
         82      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.84 ms | 1404 KiB | 27 Q