3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{"Template[URL]":"asdasdda.com","Template[UPC]":"548454854631… Example","FieldHow to Answer":"20"}'; $output = json_decode($json); print_r($output); $newArray = array(); $array = $output; foreach ($array as $key=>$value) { preg_match("/\[(.+)\]/",$key,$match); $newKey = preg_replace("/\[.+\]/","",$key); $newArray[$newKey][$match[1]] = $value; } print_r($newArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 29
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/qsKtF
function name:  (null)
number of ops:  34
compiled vars:  !0 = $json, !1 = $output, !2 = $newArray, !3 = $array, !4 = $value, !5 = $key, !6 = $match, !7 = $newKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%22Template%5BURL%5D%22%3A%22asdasdda.com%22%2C%22Template%5BUPC%5D%22%3A%22548454854631%E2%80%A6+Example%22%2C%22FieldHow+to+Answer%22%3A%2220%22%7D'
    4     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $9      
          4        ASSIGN                                                   !1, $9
    5     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
    8     8        ASSIGN                                                   !2, <array>
    9     9        ASSIGN                                                   !3, !1
   10    10      > FE_RESET_R                                       $14     !3, ->29
         11    > > FE_FETCH_R                                       ~15     $14, !4, ->29
         12    >   ASSIGN                                                   !5, ~15
   11    13        INIT_FCALL                                               'preg_match'
         14        SEND_VAL                                                 '%2F%5C%5B%28.%2B%29%5C%5D%2F'
         15        SEND_VAR                                                 !5
         16        SEND_REF                                                 !6
         17        DO_ICALL                                                 
   12    18        INIT_FCALL                                               'preg_replace'
         19        SEND_VAL                                                 '%2F%5C%5B.%2B%5C%5D%2F'
         20        SEND_VAL                                                 ''
         21        SEND_VAR                                                 !5
         22        DO_ICALL                                         $18     
         23        ASSIGN                                                   !7, $18
   13    24        FETCH_DIM_R                                      ~21     !6, 1
         25        FETCH_DIM_W                                      $20     !2, !7
         26        ASSIGN_DIM                                               $20, ~21
         27        OP_DATA                                                  !4
   10    28      > JMP                                                      ->11
         29    >   FE_FREE                                                  $14
   15    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161 ms | 1388 KiB | 21 Q