3v4l.org

run code in 300+ PHP versions simultaneously
<?php $matches = [ [ 'insult' => [ 'text' => 'You fight like a Dairy Farmer!', 'maxDistance' => 15, ], 'response' => [ 'text' => 'How appropriate! You fight like a cow!', 'maxDistance' => 20, ], ], [ 'insult' => [ 'text' => 'This is the END for you, you gutter crawling cur!', 'maxDistance' => 32, ], 'response' => [ 'text' => 'And I\'ve got a little TIP for you, get the POINT?', 'maxDistance' => 25, ], ], ]; $search = "This is the end for you, gutter-crawling cur!"; $closestSet = null; $closestScore = 0; foreach ($matches as $set) { $score = similar_text($search, $set['insult']['text']); var_dump($score); if ($score > $closestScore) { $closestScore = $score; $closestSet = $set; } } echo "---", PHP_EOL; var_dump($search, $closestScore, $closestSet);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 21
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/jEa2n
function name:  (null)
number of ops:  30
compiled vars:  !0 = $matches, !1 = $search, !2 = $closestSet, !3 = $closestScore, !4 = $set, !5 = $score
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   26     1        ASSIGN                                                   !1, 'This+is+the+end+for+you%2C+gutter-crawling+cur%21'
   27     2        ASSIGN                                                   !2, null
   28     3        ASSIGN                                                   !3, 0
   30     4      > FE_RESET_R                                       $10     !0, ->21
          5    > > FE_FETCH_R                                               $10, !4, ->21
   31     6    >   INIT_FCALL                                               'similar_text'
          7        SEND_VAR                                                 !1
          8        FETCH_DIM_R                                      ~11     !4, 'insult'
          9        FETCH_DIM_R                                      ~12     ~11, 'text'
         10        SEND_VAL                                                 ~12
         11        DO_ICALL                                         $13     
         12        ASSIGN                                                   !5, $13
   32    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !5
         15        DO_ICALL                                                 
   33    16        IS_SMALLER                                               !3, !5
         17      > JMPZ                                                     ~16, ->20
   34    18    >   ASSIGN                                                   !3, !5
   35    19        ASSIGN                                                   !2, !4
   30    20    > > JMP                                                      ->5
         21    >   FE_FREE                                                  $10
   39    22        ECHO                                                     '---'
         23        ECHO                                                     '%0A'
   41    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !1
         26        SEND_VAR                                                 !3
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.32 ms | 1002 KiB | 15 Q