3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subject = 'in the middle 9850112686331(14-15): for Rocco A & Stephanie'; $arr = preg_split('/[^a-z0-9\-()]/i', $subject); $candidates = []; for ($i = 0; $i < count($arr); $i++) { for ($j = $i; $j < count($arr); $j++) { $candidates[] = trim(implode(' ', array_slice($arr, $i, $j - $i + 1))); } } usort($candidates, function($a, $b) { return strlen($b) - strlen($a); }); foreach($candidates as $candidate){ echo $candidate . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 9
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 45
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 11
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 9
Branch analysis from position: 35
Branch analysis from position: 9
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 11
Branch analysis from position: 31
Branch analysis from position: 11
filename:       /in/4I7d1
function name:  (null)
number of ops:  47
compiled vars:  !0 = $subject, !1 = $arr, !2 = $candidates, !3 = $i, !4 = $j, !5 = $candidate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'in+the+middle+9850112686331%2814-15%29%3A+for+Rocco+A+%26+Stephanie'
    5     1        INIT_FCALL                                               'preg_split'
          2        SEND_VAL                                                 '%2F%5B%5Ea-z0-9%5C-%28%29%5D%2Fi'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
    6     6        ASSIGN                                                   !2, <array>
    7     7        ASSIGN                                                   !3, 0
          8      > JMP                                                      ->32
    8     9    >   ASSIGN                                                   !4, !3
         10      > JMP                                                      ->28
    9    11    >   INIT_FCALL                                               'trim'
         12        INIT_FCALL                                               'implode'
         13        SEND_VAL                                                 '+'
         14        INIT_FCALL                                               'array_slice'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !3
         17        SUB                                              ~13     !4, !3
         18        ADD                                              ~14     ~13, 1
         19        SEND_VAL                                                 ~14
         20        DO_ICALL                                         $15     
         21        SEND_VAR                                                 $15
         22        DO_ICALL                                         $16     
         23        SEND_VAR                                                 $16
         24        DO_ICALL                                         $17     
         25        ASSIGN_DIM                                               !2
         26        OP_DATA                                                  $17
    8    27        PRE_INC                                                  !4
         28    >   COUNT                                            ~19     !1
         29        IS_SMALLER                                               !4, ~19
         30      > JMPNZ                                                    ~20, ->11
    7    31    >   PRE_INC                                                  !3
         32    >   COUNT                                            ~22     !1
         33        IS_SMALLER                                               !3, ~22
         34      > JMPNZ                                                    ~23, ->9
   13    35    >   INIT_FCALL                                               'usort'
         36        SEND_REF                                                 !2
         37        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F4I7d1%3A13%240'
   15    38        SEND_VAL                                                 ~24
         39        DO_ICALL                                                 
   17    40      > FE_RESET_R                                       $26     !2, ->45
         41    > > FE_FETCH_R                                               $26, !5, ->45
   18    42    >   CONCAT                                           ~27     !5, '%0A'
         43        ECHO                                                     ~27
   17    44      > JMP                                                      ->41
         45    >   FE_FREE                                                  $26
   19    46      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F4I7d1%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I7d1
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        STRLEN                                           ~2      !1
          3        STRLEN                                           ~3      !0
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   15     6*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.27 ms | 1400 KiB | 23 Q