3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = <<<EOD The spread of a deadly new virus is accelerating, Chinese President Xi Jinping warned, after holding a special government meeting on the Lunar New Year public holiday. The country is facing a "grave situation" Mr Xi told senior officials. The coronavirus has killed at least 42 people and infected some 1,400 since its discovery in the city of Wuhan. Meanwhile, UK-based researchers have warned of a real possibility that China will not be able to contain the virus. Travel restrictions have come in place in several affected cities. From Sunday, private vehicles will be banned from central districts of Wuhan, the source of the outbreak. EOD; $words = explode(' ', $text); $concordance = 10; $results = array(); foreach (array_keys($words, 'in') as $idx) { $results[] = implode(' ', array_slice($words, max($idx - $concordance, 0), $concordance * 2 + 1)); } print_r($results); $words = explode(' ', $text); $concordance = 10; $results = array(); $last = 0; foreach (array_keys($words, 'in') as $idx) { if ($idx < $last) continue; $results[] = implode(' ', array_slice($words, max($idx - $concordance, 0), $concordance * 2 + 1)); $last = $idx + $concordance; } print_r($results);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 33
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 33
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 75
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 75
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 54
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
Branch analysis from position: 33
filename:       /in/9aa8Z
function name:  (null)
number of ops:  80
compiled vars:  !0 = $text, !1 = $words, !2 = $concordance, !3 = $results, !4 = $idx, !5 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'The+spread+of+a+deadly+new+virus+is+accelerating%2C+Chinese+President+Xi+Jinping+warned%2C+after+holding+a+special+government+meeting+on+the+Lunar+New+Year+public+holiday.%0AThe+country+is+facing+a+%22grave+situation%22+Mr+Xi+told+senior+officials.%0AThe+coronavirus+has+killed+at+least+42+people+and+infected+some+1%2C400+since+its+discovery+in+the+city+of+Wuhan.%0AMeanwhile%2C+UK-based+researchers+have+warned+of+a+real+possibility+that+China+will+not+be+able+to+contain+the+virus.%0ATravel+restrictions+have+come+in+place+in+several+affected+cities.+From+Sunday%2C+private+vehicles+will+be+banned+from+central+districts+of+Wuhan%2C+the+source+of+the+outbreak.'
   11     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   12     6        ASSIGN                                                   !2, 10
   13     7        ASSIGN                                                   !3, <array>
   14     8        INIT_FCALL                                               'array_keys'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 'in'
         11        DO_ICALL                                         $11     
         12      > FE_RESET_R                                       $12     $11, ->33
         13    > > FE_FETCH_R                                               $12, !4, ->33
   15    14    >   INIT_FCALL                                               'implode'
         15        SEND_VAL                                                 '+'
         16        INIT_FCALL                                               'array_slice'
         17        SEND_VAR                                                 !1
         18        INIT_FCALL                                               'max'
         19        SUB                                              ~14     !4, !2
         20        SEND_VAL                                                 ~14
         21        SEND_VAL                                                 0
         22        DO_ICALL                                         $15     
         23        SEND_VAR                                                 $15
         24        MUL                                              ~16     !2, 2
         25        ADD                                              ~17     ~16, 1
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        DO_ICALL                                         $19     
         30        ASSIGN_DIM                                               !3
         31        OP_DATA                                                  $19
   14    32      > JMP                                                      ->13
         33    >   FE_FREE                                                  $12
   17    34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                                 
   19    37        INIT_FCALL                                               'explode'
         38        SEND_VAL                                                 '+'
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $21     
         41        ASSIGN                                                   !1, $21
   20    42        ASSIGN                                                   !2, 10
   21    43        ASSIGN                                                   !3, <array>
   22    44        ASSIGN                                                   !5, 0
   23    45        INIT_FCALL                                               'array_keys'
         46        SEND_VAR                                                 !1
         47        SEND_VAL                                                 'in'
         48        DO_ICALL                                         $26     
         49      > FE_RESET_R                                       $27     $26, ->75
         50    > > FE_FETCH_R                                               $27, !4, ->75
   24    51    >   IS_SMALLER                                               !4, !5
         52      > JMPZ                                                     ~28, ->54
         53    > > JMP                                                      ->50
   25    54    >   INIT_FCALL                                               'implode'
         55        SEND_VAL                                                 '+'
         56        INIT_FCALL                                               'array_slice'
         57        SEND_VAR                                                 !1
         58        INIT_FCALL                                               'max'
         59        SUB                                              ~30     !4, !2
         60        SEND_VAL                                                 ~30
         61        SEND_VAL                                                 0
         62        DO_ICALL                                         $31     
         63        SEND_VAR                                                 $31
         64        MUL                                              ~32     !2, 2
         65        ADD                                              ~33     ~32, 1
         66        SEND_VAL                                                 ~33
         67        DO_ICALL                                         $34     
         68        SEND_VAR                                                 $34
         69        DO_ICALL                                         $35     
         70        ASSIGN_DIM                                               !3
         71        OP_DATA                                                  $35
   26    72        ADD                                              ~36     !4, !2
         73        ASSIGN                                                   !5, ~36
   23    74      > JMP                                                      ->50
         75    >   FE_FREE                                                  $27
   28    76        INIT_FCALL                                               'print_r'
         77        SEND_VAR                                                 !3
         78        DO_ICALL                                                 
         79      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.6 ms | 1409 KiB | 25 Q