3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '[ ["key1", "value1"], ["key2", "value2"], ["key3", "value3"] ]'; preg_match_all('/(\[("(.*?)"), ("(.*?)")\])/i', $str, $matches); //Now we have in $matches[3] and $matches[5] the keys and the values //and we would now turn this into an array using a loop $new_array = array(); for($k = 0; $k < count($matches[3]); $k++) { $new_array[$matches[3][$k]] = $matches[5][$k]; } var_dump($new_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 9
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 9
Branch analysis from position: 20
Branch analysis from position: 9
filename:       /in/u3jpl
function name:  (null)
number of ops:  24
compiled vars:  !0 = $str, !1 = $matches, !2 = $new_array, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%5B+%5B%22key1%22%2C+%22value1%22%5D%2C+%5B%22key2%22%2C+%22value2%22%5D%2C+%5B%22key3%22%2C+%22value3%22%5D+%5D'
    3     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%28%5C%5B%28%22%28.%2A%3F%29%22%29%2C+%28%22%28.%2A%3F%29%22%29%5C%5D%29%2Fi'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    7     6        ASSIGN                                                   !2, <array>
    8     7        ASSIGN                                                   !3, 0
          8      > JMP                                                      ->16
    9     9    >   FETCH_DIM_R                                      ~8      !1, 3
         10        FETCH_DIM_R                                      ~9      ~8, !3
         11        FETCH_DIM_R                                      ~11     !1, 5
         12        FETCH_DIM_R                                      ~12     ~11, !3
         13        ASSIGN_DIM                                               !2, ~9
         14        OP_DATA                                                  ~12
    8    15        PRE_INC                                                  !3
         16    >   FETCH_DIM_R                                      ~14     !1, 3
         17        COUNT                                            ~15     ~14
         18        IS_SMALLER                                               !3, ~15
         19      > JMPNZ                                                    ~16, ->9
   12    20    >   INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.94 ms | 1395 KiB | 17 Q