3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = '[ { "1": "tag_es1;tag_es2;tag_es3", "2": "tag_en1;tag_en2;tag_en3" }, { "1": "tag_es1;tag_es2", "2": "tag_en1;tag_en2" } ]'; $arr = json_decode($json, true); foreach($arr as $key1 => $sub){ foreach($sub as $item){ $temp[] = explode(";", $item); } foreach($temp[0] as $key2 => $val){ $new[$key1][]= array_combine([1,2],array_column($temp, $key2)); } $temp =[]; } Var_dump($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 38
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 38
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 35
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 35
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 35
Branch analysis from position: 18
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/qgCA1
function name:  (null)
number of ops:  43
compiled vars:  !0 = $json, !1 = $arr, !2 = $sub, !3 = $key1, !4 = $item, !5 = $temp, !6 = $val, !7 = $key2, !8 = $new
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%5B%0A++%7B%0A++++%221%22%3A+%22tag_es1%3Btag_es2%3Btag_es3%22%2C%0A++++%222%22%3A+%22tag_en1%3Btag_en2%3Btag_en3%22%0A++%7D%2C%0A++%7B%0A++++%221%22%3A+%22tag_es1%3Btag_es2%22%2C%0A++++%222%22%3A+%22tag_en1%3Btag_en2%22%0A++%7D%0A%5D'
   13     1        INIT_FCALL                                                   'json_decode'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     <true>
          4        DO_ICALL                                             $10     
          5        ASSIGN                                                       !1, $10
   14     6      > FE_RESET_R                                           $12     !1, ->38
          7    > > FE_FETCH_R                                           ~13     $12, !2, ->38
          8    >   ASSIGN                                                       !3, ~13
   15     9      > FE_RESET_R                                           $15     !2, ->18
         10    > > FE_FETCH_R                                                   $15, !4, ->18
   16    11    >   INIT_FCALL                                                   'explode'
         12        SEND_VAL                                                     '%3B'
         13        SEND_VAR                                                     !4
         14        DO_ICALL                                             $17     
         15        ASSIGN_DIM                                                   !5
         16        OP_DATA                                                      $17
   15    17      > JMP                                                          ->10
         18    >   FE_FREE                                                      $15
   18    19        FETCH_DIM_R                                          ~18     !5, 0
         20      > FE_RESET_R                                           $19     ~18, ->35
         21    > > FE_FETCH_R                                           ~20     $19, !6, ->35
         22    >   ASSIGN                                                       !7, ~20
   19    23        INIT_FCALL                                                   'array_combine'
         24        SEND_VAL                                                     <array>
         25        INIT_FCALL                                                   'array_column'
         26        SEND_VAR                                                     !5
         27        SEND_VAR                                                     !7
         28        DO_ICALL                                             $24     
         29        SEND_VAR                                                     $24
         30        DO_ICALL                                             $25     
         31        FETCH_DIM_W                                          $22     !8, !3
         32        ASSIGN_DIM                                                   $22
         33        OP_DATA                                                      $25
   18    34      > JMP                                                          ->21
         35    >   FE_FREE                                                      $19
   21    36        ASSIGN                                                       !5, <array>
   14    37      > JMP                                                          ->7
         38    >   FE_FREE                                                      $12
   23    39        INIT_FCALL                                                   'var_dump'
         40        SEND_VAR                                                     !8
         41        DO_ICALL                                                     
         42      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
144.24 ms | 2369 KiB | 18 Q