3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rSplitReverse($string) { preg_match_all("/\(((?:(?>[^()]+)|(?R))*)\)/", $string, $matches); foreach ($matches[1] as &$m) { if (preg_match_all("/(\((?:(?>[^()]+)|(?R))*\))|[^(),]+/", $m, $items, PREG_SET_ORDER)) { $first = array_shift($items)[0]; foreach ($items as &$item) { $item = isset($item[1]) ? rSplitReverse($item[0]) : $item[0]; } $m = "$first," . implode(',', array_reverse($items)); } } return '(' . implode('),(', array_reverse($matches[1])) . ')'; } echo rSplitReverse('(X,1,1,3),(X,1,1,3),(X,@2,@2,@2,@2,@2,(Y,1))');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IfMW6
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'rsplitreverse'
          1        SEND_VAL                                                 '%28X%2C1%2C1%2C3%29%2C%28X%2C1%2C1%2C3%29%2C%28X%2C%402%2C%402%2C%402%2C%402%2C%402%2C%28Y%2C1%29%29'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function rsplitreverse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 8, Position 2 = 49
Branch analysis from position: 8
2 jumps found. (Code = 126) Position 1 = 9, Position 2 = 49
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 48
Branch analysis from position: 16
2 jumps found. (Code = 125) Position 1 = 22, Position 2 = 36
Branch analysis from position: 22
2 jumps found. (Code = 126) Position 1 = 23, Position 2 = 36
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 36
Branch analysis from position: 48
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
filename:       /in/IfMW6
function name:  rSplitReverse
number of ops:  62
compiled vars:  !0 = $string, !1 = $matches, !2 = $m, !3 = $items, !4 = $first, !5 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%5C%28%28%28%3F%3A%28%3F%3E%5B%5E%28%29%5D%2B%29%7C%28%3FR%29%29%2A%29%5C%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    5     6        FETCH_DIM_W                                      $7      !1, 1
          7      > FE_RESET_RW                                      $8      $7, ->49
          8    > > FE_FETCH_RW                                              $8, !2, ->49
    6     9    >   INIT_FCALL                                               'preg_match_all'
         10        SEND_VAL                                                 '%2F%28%5C%28%28%3F%3A%28%3F%3E%5B%5E%28%29%5D%2B%29%7C%28%3FR%29%29%2A%5C%29%29%7C%5B%5E%28%29%2C%5D%2B%2F'
         11        SEND_VAR                                                 !2
         12        SEND_REF                                                 !3
         13        SEND_VAL                                                 2
         14        DO_ICALL                                         $9      
         15      > JMPZ                                                     $9, ->48
    7    16    >   INIT_FCALL                                               'array_shift'
         17        SEND_REF                                                 !3
         18        DO_ICALL                                         $10     
         19        FETCH_DIM_R                                      ~11     $10, 0
         20        ASSIGN                                                   !4, ~11
    8    21      > FE_RESET_RW                                      $13     !3, ->36
         22    > > FE_FETCH_RW                                              $13, !5, ->36
    9    23    >   ISSET_ISEMPTY_DIM_OBJ                         0          !5, 1
         24      > JMPZ                                                     ~14, ->32
         25    >   INIT_FCALL_BY_NAME                                       'rSplitReverse'
         26        CHECK_FUNC_ARG                                           
         27        FETCH_DIM_FUNC_ARG                               $15     !5, 0
         28        SEND_FUNC_ARG                                            $15
         29        DO_FCALL                                      0  $16     
         30        QM_ASSIGN                                        ~17     $16
         31      > JMP                                                      ->34
         32    >   FETCH_DIM_R                                      ~18     !5, 0
         33        QM_ASSIGN                                        ~17     ~18
         34    >   ASSIGN                                                   !5, ~17
    8    35      > JMP                                                      ->22
         36    >   FE_FREE                                                  $13
   11    37        NOP                                                      
         38        FAST_CONCAT                                      ~20     !4, '%2C'
         39        INIT_FCALL                                               'implode'
         40        SEND_VAL                                                 '%2C'
         41        INIT_FCALL                                               'array_reverse'
         42        SEND_VAR                                                 !3
         43        DO_ICALL                                         $21     
         44        SEND_VAR                                                 $21
         45        DO_ICALL                                         $22     
         46        CONCAT                                           ~23     ~20, $22
         47        ASSIGN                                                   !2, ~23
    5    48    > > JMP                                                      ->8
         49    >   FE_FREE                                                  $8
   14    50        INIT_FCALL                                               'implode'
         51        SEND_VAL                                                 '%29%2C%28'
         52        INIT_FCALL                                               'array_reverse'
         53        FETCH_DIM_R                                      ~25     !1, 1
         54        SEND_VAL                                                 ~25
         55        DO_ICALL                                         $26     
         56        SEND_VAR                                                 $26
         57        DO_ICALL                                         $27     
         58        CONCAT                                           ~28     '%28', $27
         59        CONCAT                                           ~29     ~28, '%29'
         60      > RETURN                                                   ~29
   15    61*     > RETURN                                                   null

End of function rsplitreverse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.62 ms | 1021 KiB | 18 Q