3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['アーチ橋', 'アーチの過重負担方法による分類', '無補剛アーチ', '固定アーチ'], ['アーチ橋', 'アーチの過重負担方法による分類', '無補剛アーチ', '2ヒンジアーチ'], ['アーチ橋', 'アーチの過重負担方法による分類', '補剛アーチ', 'ランガー', 'ランガー'], ['アーチ橋', 'アーチの過重負担方法による分類', '補剛アーチ', 'ランガー', 'トラストランガー'], ['アーチ橋', 'アーチの過重負担方法による分類', '補剛アーチ', 'ローゼ', 'ローゼ'], ['アーチ橋', 'アーチの過重負担方法による分類', '補剛アーチ', 'ローゼ', '逆ローゼ'], ['アーチ橋', 'アーチ部材の形態による分類', 'ソリッドリブアーチ'], ['アーチ橋', 'アーチ部材の形態による分類', 'パイプアーチ'], ['トラス橋', 'トラスの支持方法による分類', '単純トラス'], ['トラス橋', 'トラスの支持方法による分類', '連続トラス'], ['トラス橋', 'トラスの形状による分類', '平行弦トラス'], ['トラス橋', 'トラスの形状による分類', '曲弦トラス'], ]; $result = []; foreach ($data as $row) { $value = \end($row); $key = \key($row); unset($row[$key]); $keys = $row; $tmp = &$result; foreach ($keys as $key) { if (!isset($tmp[$key])) { $tmp[$key] = null; } $tmp = &$tmp[$key]; } if ($tmp === null) { $tmp = $value; } elseif (!\is_array($tmp)) { $tmp = [$tmp, $value]; } else { $tmp[] = $value; } } echo \json_encode($result, \JSON_PRETTY_PRINT|\JSON_UNESCAPED_UNICODE);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 40
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 40
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 22
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 37
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/8gr7d
function name:  (null)
number of ops:  47
compiled vars:  !0 = $data, !1 = $result, !2 = $row, !3 = $value, !4 = $key, !5 = $keys, !6 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, <array>
   20     2      > FE_RESET_R                                       $9      !0, ->40
          3    > > FE_FETCH_R                                               $9, !2, ->40
   21     4    >   INIT_FCALL                                               'end'
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !3, $10
   22     8        INIT_FCALL                                               'key'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $12     
         11        ASSIGN                                                   !4, $12
   23    12        UNSET_DIM                                                !2, !4
   25    13        ASSIGN                                                   !5, !2
   27    14        ASSIGN_REF                                               !6, !1
   29    15      > FE_RESET_R                                       $16     !5, ->25
         16    > > FE_FETCH_R                                               $16, !4, ->25
   30    17    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~17     !6, !4
         18        BOOL_NOT                                         ~18     ~17
         19      > JMPZ                                                     ~18, ->22
   31    20    >   ASSIGN_DIM                                               !6, !4
         21        OP_DATA                                                  null
   34    22    >   FETCH_DIM_W                                      $20     !6, !4
         23        ASSIGN_REF                                               !6, $20
   29    24      > JMP                                                      ->16
         25    >   FE_FREE                                                  $16
   37    26        TYPE_CHECK                                    2          !6
         27      > JMPZ                                                     ~22, ->30
   38    28    >   ASSIGN                                                   !6, !3
   37    29      > JMP                                                      ->39
   39    30    >   TYPE_CHECK                                  128  ~24     !6
         31        BOOL_NOT                                         ~25     ~24
         32      > JMPZ                                                     ~25, ->37
   40    33    >   INIT_ARRAY                                       ~26     !6
         34        ADD_ARRAY_ELEMENT                                ~26     !3
         35        ASSIGN                                                   !6, ~26
   39    36      > JMP                                                      ->39
   42    37    >   ASSIGN_DIM                                               !6
         38        OP_DATA                                                  !3
   20    39    > > JMP                                                      ->3
         40    >   FE_FREE                                                  $9
   46    41        INIT_FCALL                                               'json_encode'
         42        SEND_VAR                                                 !1
         43        SEND_VAL                                                 384
         44        DO_ICALL                                         $29     
         45        ECHO                                                     $29
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.46 ms | 1012 KiB | 16 Q