3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['mango', 'orange', 'apple'], ['abc'], ['ctp'], ['pqr', 'cst', 'dtc'], ['cbx'], ['xyz'], ['atc'], ]; foreach($data as $key => $d){ if(count($d)>1){ $mergeTo = $key; // store key where to merge to continue; // go to next item } $data[$mergeTo]["additional"][] = $d; // add value to $mergeTo unset($data[$key]); // unset the value from the main array } $data = array_values($data); // reset keys var_export($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/BmXUZ
function name:  (null)
number of ops:  24
compiled vars:  !0 = $data, !1 = $d, !2 = $key, !3 = $mergeTo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1      > FE_RESET_R                                       $5      !0, ->15
          2    > > FE_FETCH_R                                       ~6      $5, !1, ->15
          3    >   ASSIGN                                                   !2, ~6
   14     4        COUNT                                            ~8      !1
          5        IS_SMALLER                                               1, ~8
          6      > JMPZ                                                     ~9, ->9
   15     7    >   ASSIGN                                                   !3, !2
   16     8      > JMP                                                      ->2
   18     9    >   FETCH_DIM_W                                      $11     !0, !3
         10        FETCH_DIM_W                                      $12     $11, 'additional'
         11        ASSIGN_DIM                                               $12
         12        OP_DATA                                                  !1
   19    13        UNSET_DIM                                                !0, !2
   13    14      > JMP                                                      ->2
         15    >   FE_FREE                                                  $5
   21    16        INIT_FCALL                                               'array_values'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $14     
         19        ASSIGN                                                   !0, $14
   22    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.2 ms | 990 KiB | 15 Q