3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '[1,[01,11,12] ,4 ,5, [20,21,22]]'; $parts = preg_split('/,(?![^\[]*\])/', $string, -1, PREG_SPLIT_DELIM_CAPTURE); $output = array(); foreach ($parts as $part) { $part = trim($part, '[] '); $output[] = explode(',', $part); } print_r($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/v4b9i
function name:  (null)
number of ops:  28
compiled vars:  !0 = $string, !1 = $parts, !2 = $output, !3 = $part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B1%2C%5B01%2C11%2C12%5D+%2C4+%2C5%2C+%5B20%2C21%2C22%5D%5D'
    4     1        INIT_FCALL                                               'preg_split'
          2        SEND_VAL                                                 '%2F%2C%28%3F%21%5B%5E%5C%5B%5D%2A%5C%5D%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 -1
          5        SEND_VAL                                                 2
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !1, $5
    5     8        ASSIGN                                                   !2, <array>
    6     9      > FE_RESET_R                                       $8      !1, ->23
         10    > > FE_FETCH_R                                               $8, !3, ->23
    7    11    >   INIT_FCALL                                               'trim'
         12        SEND_VAR                                                 !3
         13        SEND_VAL                                                 '%5B%5D+'
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !3, $9
    8    16        INIT_FCALL                                               'explode'
         17        SEND_VAL                                                 '%2C'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $12     
         20        ASSIGN_DIM                                               !2
         21        OP_DATA                                                  $12
    6    22      > JMP                                                      ->10
         23    >   FE_FREE                                                  $8
   10    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.71 ms | 1002 KiB | 17 Q