3v4l.org

run code in 500+ 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 = 54
Branch analysis from position: 9
2 jumps found. (Code = 126) Position 1 = 10, Position 2 = 54
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 23
2 jumps found. (Code = 47) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 53
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 31
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
filename:       /in/jrBhD
function name:  (null)
number of ops:  64
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, ->54
          9    > > FE_FETCH_RW                                                  $9, !2, ->54
    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, ->23
    7    16    >   FETCH_DIM_R                                          ~11     !3, 1
         17        FRAMELESS_ICALL_3                str_replace         ~12     <array>, <array>
         18        OP_DATA                                                      ~11
         19        CONCAT                                               ~13     '%22', ~12
         20        CONCAT                                               ~14     ~13, '%22'
         21        ASSIGN                                                       !2, ~14
    8    22      > JMP                                                          ->9
   10    23    >   INIT_FCALL                                                   'strtolower'
         24        SEND_VAR                                                     !2
         25        DO_ICALL                                             $16     
         26        ASSIGN                                                       !4, $16
   11    27        IS_EQUAL                                             ~18     !4, 'true'
         28      > JMPNZ_EX                                             ~18     ~18, ->31
         29    >   IS_EQUAL                                             ~19     !4, 'false'
         30        BOOL                                                 ~18     ~19
         31    > > JMPZ                                                         ~18, ->34
   12    32    >   ASSIGN                                                       !2, !4
   13    33      > JMP                                                          ->9
   15    34    >   INIT_FCALL                                                   'preg_match'
         35        SEND_VAL                                                     '%2F%5E%5C%2B%5Cs%2A%28%5Cd%2B%29%24%2F'
         36        SEND_VAR                                                     !2
         37        SEND_REF                                                     !3
         38        DO_ICALL                                             $21     
         39      > JMPZ                                                         $21, ->43
   16    40    >   FETCH_DIM_R                                          ~22     !3, 1
         41        ASSIGN                                                       !2, ~22
   17    42      > JMP                                                          ->9
   19    43    >   INIT_FCALL                                                   'preg_match'
         44        SEND_VAL                                                     '%2F%5E-%5Cs%2A%28%5Cd%2B%29%24%2F'
         45        SEND_VAR                                                     !2
         46        SEND_REF                                                     !3
         47        DO_ICALL                                             $24     
         48      > JMPZ                                                         $24, ->53
   20    49    >   FETCH_DIM_R                                          ~25     !3, 1
         50        CONCAT                                               ~26     '-', ~25
         51        ASSIGN                                                       !2, ~26
   21    52      > JMP                                                          ->9
    5    53    > > JMP                                                          ->9
         54    >   FE_FREE                                                      $9
   24    55        FRAMELESS_ICALL_2                implode             ~28     '', !1
         56        ASSIGN                                                       !5, ~28
   25    57        INIT_FCALL                                                   'var_dump'
         58        INIT_FCALL                                                   'json_decode'
         59        SEND_VAR                                                     !5
         60        DO_ICALL                                             $30     
         61        SEND_VAR                                                     $30
         62        DO_ICALL                                                     
         63      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
179.32 ms | 2152 KiB | 18 Q