3v4l.org

run code in 300+ PHP versions simultaneously
<?php function combineColumns(array $row, $separator) // {{{ { $combined = array(); foreach ($row as $key => $value) { if (false !== strpos($key, $separator)) { $parts = explode($separator, $key); $pkey = array_pop($parts); $ptr = &$combined; while (null !== ($part = array_shift($parts))) { if (!isset($ptr[$part]) || !is_array($ptr[$part])) { $ptr[$part] = array(); } $ptr = &$ptr[$part]; } $ptr[$pkey] = $value; unset($ptr); } else { $combined[$key] = $value; } } return $combined; } print_r(combineColumns(array( 'A' => 1, 'B_C' => 2, 'B_D_A' => 3, 'D_K_F' => 4, ), '_'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4KDnR
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'combinecolumns'
   32     2        SEND_VAL                                                 <array>
   36     3        SEND_VAL                                                 '_'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function combinecolumns:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 48
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 48
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 45
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 23
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 23
2 jumps found. (Code = 47) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 23
Branch analysis from position: 41
Branch analysis from position: 23
Branch analysis from position: 33
Branch analysis from position: 30
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/4KDnR
function name:  combineColumns
number of ops:  51
compiled vars:  !0 = $row, !1 = $separator, !2 = $combined, !3 = $value, !4 = $key, !5 = $parts, !6 = $pkey, !7 = $ptr, !8 = $part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $10     !0, ->48
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->48
          5    >   ASSIGN                                                   !4, ~11
    8     6        INIT_FCALL                                               'strpos'
          7        SEND_VAR                                                 !4
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $13     
         10        TYPE_CHECK                                  1018          $13
         11      > JMPZ                                                     ~14, ->45
    9    12    >   INIT_FCALL                                               'explode'
         13        SEND_VAR                                                 !1
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                         $15     
         16        ASSIGN                                                   !5, $15
   10    17        INIT_FCALL                                               'array_pop'
         18        SEND_REF                                                 !5
         19        DO_ICALL                                         $17     
         20        ASSIGN                                                   !6, $17
   11    21        ASSIGN_REF                                               !7, !2
   13    22      > JMP                                                      ->35
   14    23    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~20     !7, !8
         24        BOOL_NOT                                         ~21     ~20
         25      > JMPNZ_EX                                         ~21     ~21, ->30
         26    >   FETCH_DIM_R                                      ~22     !7, !8
         27        TYPE_CHECK                                  128  ~23     ~22
         28        BOOL_NOT                                         ~24     ~23
         29        BOOL                                             ~21     ~24
         30    > > JMPZ                                                     ~21, ->33
   15    31    >   ASSIGN_DIM                                               !7, !8
         32        OP_DATA                                                  <array>
   17    33    >   FETCH_DIM_W                                      $26     !7, !8
         34        ASSIGN_REF                                               !7, $26
   13    35    >   INIT_FCALL                                               'array_shift'
         36        SEND_REF                                                 !5
         37        DO_ICALL                                         $28     
         38        ASSIGN                                           ~29     !8, $28
         39        TYPE_CHECK                                  1020          ~29
         40      > JMPNZ                                                    ~30, ->23
   20    41    >   ASSIGN_DIM                                               !7, !6
         42        OP_DATA                                                  !3
   21    43        UNSET_CV                                                 !7
         44      > JMP                                                      ->47
   24    45    >   ASSIGN_DIM                                               !2, !4
         46        OP_DATA                                                  !3
    7    47    > > JMP                                                      ->4
         48    >   FE_FREE                                                  $10
   28    49      > RETURN                                                   !2
   29    50*     > RETURN                                                   null

End of function combinecolumns

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.44 ms | 1394 KiB | 24 Q