3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) { // PHP 8.1 deprecates nulls for $limit and $flags $limit = $limit === null ? -1 : $limit; $flags = $flags === null ? 0 : $flags; // the bug only happens on PHP 5.2 when using the u modifier if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) { return preg_split($pattern.$modifiers, $subject, $limit, $flags); } // preg_split is bugged - try alternative solution $ret = array(); while (($nl = strpos($subject, "\n")) !== FALSE) { $ret = array_merge($ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags)); $ret[] = "\n"; $subject = substr($subject, ($nl + 1)); } if (strlen($subject) > 0) { $ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags)); } return $ret; } var_export( pregSplit('//','u', 'LIVE (foo.bar) bar.com (UA-12345-1, 1234567) - Räkerkerkrkrkr', -1, PREG_SPLIT_NO_EMPTY));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0iF1c
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'var_export'
          1        INIT_FCALL                                               'pregsplit'
          2        SEND_VAL                                                 '%2F%2F'
          3        SEND_VAL                                                 'u'
          4        SEND_VAL                                                 'LIVE+%28foo.bar%29+bar.com+%28UA-12345-1%2C+1234567%29+-+R%C3%A4kerkerkrkrkr'
          5        SEND_VAL                                                 -1
          6        SEND_VAL                                                 1
          7        DO_FCALL                                      0  $0      
          8        SEND_VAR                                                 $0
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function pregsplit:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 32
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 41
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 43
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 90
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 90
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 75, Position 2 = 43
Branch analysis from position: 75
Branch analysis from position: 43
Branch analysis from position: 32
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 32
Branch analysis from position: 23
Branch analysis from position: 32
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
Branch analysis from position: 15
filename:       /in/0iF1c
function name:  pregSplit
number of ops:  92
compiled vars:  !0 = $pattern, !1 = $modifiers, !2 = $subject, !3 = $limit, !4 = $flags, !5 = $ret, !6 = $nl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      null
          4        RECV_INIT                                        !4      null
    4     5        TYPE_CHECK                                    2          !3
          6      > JMPZ                                                     ~7, ->9
          7    >   QM_ASSIGN                                        ~8      -1
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~8      !3
         10    >   ASSIGN                                                   !3, ~8
    5    11        TYPE_CHECK                                    2          !4
         12      > JMPZ                                                     ~10, ->15
         13    >   QM_ASSIGN                                        ~11     0
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~11     !4
         16    >   ASSIGN                                                   !4, ~11
    7    17        INIT_FCALL                                               'strpos'
         18        SEND_VAR                                                 !1
         19        SEND_VAL                                                 'u'
         20        DO_ICALL                                         $13     
         21        TYPE_CHECK                                    4  ~14     $13
         22      > JMPNZ_EX                                         ~14     ~14, ->32
         23    >   INIT_FCALL                                               'preg_split'
         24        SEND_VAL                                                 '%2F%2Fu'
         25        SEND_VAL                                                 '%0A%09'
         26        SEND_VAL                                                 -1
         27        SEND_VAL                                                 1
         28        DO_ICALL                                         $15     
         29        COUNT                                            ~16     $15
         30        IS_EQUAL                                         ~17     ~16, 2
         31        BOOL                                             ~14     ~17
         32    > > JMPZ                                                     ~14, ->41
    8    33    >   INIT_FCALL                                               'preg_split'
         34        CONCAT                                           ~18     !0, !1
         35        SEND_VAL                                                 ~18
         36        SEND_VAR                                                 !2
         37        SEND_VAR                                                 !3
         38        SEND_VAR                                                 !4
         39        DO_ICALL                                         $19     
         40      > RETURN                                                   $19
   11    41    >   ASSIGN                                                   !5, <array>
   12    42      > JMP                                                      ->68
   13    43    >   INIT_FCALL                                               'array_merge'
         44        SEND_VAR                                                 !5
         45        INIT_FCALL                                               'preg_split'
         46        CONCAT                                           ~21     !0, !1
         47        SEND_VAL                                                 ~21
         48        INIT_FCALL                                               'substr'
         49        SEND_VAR                                                 !2
         50        SEND_VAL                                                 0
         51        SEND_VAR                                                 !6
         52        DO_ICALL                                         $22     
         53        SEND_VAR                                                 $22
         54        SEND_VAR                                                 !3
         55        SEND_VAR                                                 !4
         56        DO_ICALL                                         $23     
         57        SEND_VAR                                                 $23
         58        DO_ICALL                                         $24     
         59        ASSIGN                                                   !5, $24
   14    60        ASSIGN_DIM                                               !5
         61        OP_DATA                                                  '%0A'
   15    62        INIT_FCALL                                               'substr'
         63        SEND_VAR                                                 !2
         64        ADD                                              ~27     !6, 1
         65        SEND_VAL                                                 ~27
         66        DO_ICALL                                         $28     
         67        ASSIGN                                                   !2, $28
   12    68    >   INIT_FCALL                                               'strpos'
         69        SEND_VAR                                                 !2
         70        SEND_VAL                                                 '%0A'
         71        DO_ICALL                                         $30     
         72        ASSIGN                                           ~31     !6, $30
         73        TYPE_CHECK                                  1018          ~31
         74      > JMPNZ                                                    ~32, ->43
   17    75    >   STRLEN                                           ~33     !2
         76        IS_SMALLER                                               0, ~33
         77      > JMPZ                                                     ~34, ->90
   18    78    >   INIT_FCALL                                               'array_merge'
         79        SEND_VAR                                                 !5
         80        INIT_FCALL                                               'preg_split'
         81        CONCAT                                           ~35     !0, !1
         82        SEND_VAL                                                 ~35
         83        SEND_VAR                                                 !2
         84        SEND_VAR                                                 !3
         85        SEND_VAR                                                 !4
         86        DO_ICALL                                         $36     
         87        SEND_VAR                                                 $36
         88        DO_ICALL                                         $37     
         89        ASSIGN                                                   !5, $37
   20    90    > > RETURN                                                   !5
   21    91*     > RETURN                                                   null

End of function pregsplit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.68 ms | 1407 KiB | 24 Q