3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['parent 1', '10000', '20000'], ['parent 1', '15000', '21000'], ['parent 2', '13000', '22000'], ['parent 2', '11000', '5000'], ]; $new_array = array(); foreach($array as $a) { $temp = array_slice($a, 1); if(!array_key_exists($a[0], $new_array)) { $new_array[$a[0]] = array(); } array_push($new_array[$a[0]], $temp); } print_r($new_array) ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/XoivL
function name:  (null)
number of ops:  28
compiled vars:  !0 = $array, !1 = $new_array, !2 = $a, !3 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $6      !0, ->23
          3    > > FE_FETCH_R                                               $6, !2, ->23
   13     4    >   INIT_FCALL                                               'array_slice'
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !3, $7
   15     9        FETCH_DIM_R                                      ~9      !2, 0
         10        ARRAY_KEY_EXISTS                                 ~10     ~9, !1
         11        BOOL_NOT                                         ~11     ~10
         12      > JMPZ                                                     ~11, ->16
   16    13    >   FETCH_DIM_R                                      ~12     !2, 0
         14        ASSIGN_DIM                                               !1, ~12
         15        OP_DATA                                                  <array>
   19    16    >   INIT_FCALL                                               'array_push'
         17        FETCH_DIM_R                                      ~14     !2, 0
         18        FETCH_DIM_W                                      $15     !1, ~14
         19        SEND_REF                                                 $15
         20        SEND_VAR                                                 !3
         21        DO_ICALL                                                 
   12    22      > JMP                                                      ->3
         23    >   FE_FREE                                                  $6
   23    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
   24    27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.29 ms | 1003 KiB | 16 Q