3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "['text', 'te\\'\"x,2t', \"tex,t\", \"te\\\"x'#t\", true, True, [false, False, 100, +100], -100, + 10, - 20]"; $parts = preg_split('/\s*(\\\\["\']|"(?:\\\\"|[^"])*"|\'(?:\\\\\'|[^\'])*\')\s*|\s*([,\[\]])\s*/', $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); foreach ($parts as &$part) { if (preg_match("/^'(.*)'/", $part, $matches)) { $part = '"' . str_replace(array('"', "\\'"), array('\\"', "'"), $matches[1]) . '"'; continue; } $lpart = strtolower($part); if ($lpart == 'true' || $lpart == 'false') { $part = $lpart; continue; } if (preg_match('/^\+\s*(\d+)$/', $part, $matches)) { $part = $matches[1]; continue; } if (preg_match('/^-\s*(\d+)$/', $part, $matches)) { $part = '-' . $matches[1]; continue; } } $json = implode('', $parts); var_dump(json_decode($json));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 9, Position 2 = 57
Branch analysis from position: 9
2 jumps found. (Code = 126) Position 1 = 10, Position 2 = 57
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 26
2 jumps found. (Code = 47) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 46
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 56
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 34
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
filename:       /in/jrBhD
function name:  (null)
number of ops:  70
compiled vars:  !0 = $str, !1 = $parts, !2 = $part, !3 = $matches, !4 = $lpart, !5 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%27text%27%2C+%27te%5C%27%22x%2C2t%27%2C+%22tex%2Ct%22%2C+%22te%5C%22x%27%23t%22%2C+true%2C+True%2C+%5Bfalse%2C+False%2C+100%2C+%2B100%5D%2C+-100%2C+%2B+10%2C+-+++20%5D'
    4     1        INIT_FCALL                                               'preg_split'
          2        SEND_VAL                                                 '%2F%5Cs%2A%28%5C%5C%5B%22%27%5D%7C%22%28%3F%3A%5C%5C%22%7C%5B%5E%22%5D%29%2A%22%7C%27%28%3F%3A%5C%5C%27%7C%5B%5E%27%5D%29%2A%27%29%5Cs%2A%7C%5Cs%2A%28%5B%2C%5C%5B%5C%5D%5D%29%5Cs%2A%2F'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 -1
          5        SEND_VAL                                                 3
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !1, $7
    5     8      > FE_RESET_RW                                      $9      !1, ->57
          9    > > FE_FETCH_RW                                              $9, !2, ->57
    6    10    >   INIT_FCALL                                               'preg_match'
         11        SEND_VAL                                                 '%2F%5E%27%28.%2A%29%27%2F'
         12        SEND_VAR                                                 !2
         13        SEND_REF                                                 !3
         14        DO_ICALL                                         $10     
         15      > JMPZ                                                     $10, ->26
    7    16    >   INIT_FCALL                                               'str_replace'
         17        SEND_VAL                                                 <array>
         18        SEND_VAL                                                 <array>
         19        FETCH_DIM_R                                      ~11     !3, 1
         20        SEND_VAL                                                 ~11
         21        DO_ICALL                                         $12     
         22        CONCAT                                           ~13     '%22', $12
         23        CONCAT                                           ~14     ~13, '%22'
         24        ASSIGN                                                   !2, ~14
    8    25      > JMP                                                      ->9
   10    26    >   INIT_FCALL                                               'strtolower'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                         $16     
         29        ASSIGN                                                   !4, $16
   11    30        IS_EQUAL                                         ~18     !4, 'true'
         31      > JMPNZ_EX                                         ~18     ~18, ->34
         32    >   IS_EQUAL                                         ~19     !4, 'false'
         33        BOOL                                             ~18     ~19
         34    > > JMPZ                                                     ~18, ->37
   12    35    >   ASSIGN                                                   !2, !4
   13    36      > JMP                                                      ->9
   15    37    >   INIT_FCALL                                               'preg_match'
         38        SEND_VAL                                                 '%2F%5E%5C%2B%5Cs%2A%28%5Cd%2B%29%24%2F'
         39        SEND_VAR                                                 !2
         40        SEND_REF                                                 !3
         41        DO_ICALL                                         $21     
         42      > JMPZ                                                     $21, ->46
   16    43    >   FETCH_DIM_R                                      ~22     !3, 1
         44        ASSIGN                                                   !2, ~22
   17    45      > JMP                                                      ->9
   19    46    >   INIT_FCALL                                               'preg_match'
         47        SEND_VAL                                                 '%2F%5E-%5Cs%2A%28%5Cd%2B%29%24%2F'
         48        SEND_VAR                                                 !2
         49        SEND_REF                                                 !3
         50        DO_ICALL                                         $24     
         51      > JMPZ                                                     $24, ->56
   20    52    >   FETCH_DIM_R                                      ~25     !3, 1
         53        CONCAT                                           ~26     '-', ~25
         54        ASSIGN                                                   !2, ~26
   21    55      > JMP                                                      ->9
    5    56    > > JMP                                                      ->9
         57    >   FE_FREE                                                  $9
   24    58        INIT_FCALL                                               'implode'
         59        SEND_VAL                                                 ''
         60        SEND_VAR                                                 !1
         61        DO_ICALL                                         $28     
         62        ASSIGN                                                   !5, $28
   25    63        INIT_FCALL                                               'var_dump'
         64        INIT_FCALL                                               'json_decode'
         65        SEND_VAR                                                 !5
         66        DO_ICALL                                         $30     
         67        SEND_VAR                                                 $30
         68        DO_ICALL                                                 
         69      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.61 ms | 1013 KiB | 20 Q