3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(); $arr[] = array('p' => 3, 'id' => 4); $arr[] = array('p' => 3, 'id' => 5); $arr[] = array('p' => 3, 'id' => 6); $arr[] = array('p' => 2, 'id' => 3); $arr[] = array('p' => 1, 'id' => 2); $arr[] = array('p' => 1, 'id' => 7); $arr[] = array('p' => 0, 'id' => 1); $mas = array(); foreach($arr as $ind => $itm) { if(isset($mas[$itm['id']])) { $mas[$itn['p']][$itm['id']]['name'] = 'aaa'.$ind; $mas[$itn['p']][$itm['id']] = $mas[$itm['id']]; unset($mas[$itm['id']]); } else { $mas[$itm['p']][$itm['id']]['name'] = 'aaa'.$ind; } } print_r($mas);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 47
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 47
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 39
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/LcjPW
function name:  (null)
number of ops:  52
compiled vars:  !0 = $arr, !1 = $mas, !2 = $itm, !3 = $ind, !4 = $itn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN_DIM                                               !0
          2        OP_DATA                                                  <array>
    4     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  <array>
    5     5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  <array>
    6     7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  <array>
    7     9        ASSIGN_DIM                                               !0
         10        OP_DATA                                                  <array>
    8    11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  <array>
    9    13        ASSIGN_DIM                                               !0
         14        OP_DATA                                                  <array>
   11    15        ASSIGN                                                   !1, <array>
   12    16      > FE_RESET_R                                       $14     !0, ->47
         17    > > FE_FETCH_R                                       ~15     $14, !2, ->47
         18    >   ASSIGN                                                   !3, ~15
   14    19        FETCH_DIM_R                                      ~17     !2, 'id'
         20        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~17
         21      > JMPZ                                                     ~18, ->39
   16    22    >   FETCH_DIM_R                                      ~19     !4, 'p'
         23        FETCH_DIM_R                                      ~21     !2, 'id'
         24        CONCAT                                           ~24     'aaa', !3
         25        FETCH_DIM_W                                      $20     !1, ~19
         26        FETCH_DIM_W                                      $22     $20, ~21
         27        ASSIGN_DIM                                               $22, 'name'
         28        OP_DATA                                                  ~24
   17    29        FETCH_DIM_R                                      ~25     !4, 'p'
         30        FETCH_DIM_R                                      ~27     !2, 'id'
         31        FETCH_DIM_R                                      ~29     !2, 'id'
         32        FETCH_DIM_R                                      ~30     !1, ~29
         33        FETCH_DIM_W                                      $26     !1, ~25
         34        ASSIGN_DIM                                               $26, ~27
         35        OP_DATA                                                  ~30
   18    36        FETCH_DIM_R                                      ~31     !2, 'id'
         37        UNSET_DIM                                                !1, ~31
         38      > JMP                                                      ->46
   22    39    >   FETCH_DIM_R                                      ~32     !2, 'p'
         40        FETCH_DIM_R                                      ~34     !2, 'id'
         41        CONCAT                                           ~37     'aaa', !3
         42        FETCH_DIM_W                                      $33     !1, ~32
         43        FETCH_DIM_W                                      $35     $33, ~34
         44        ASSIGN_DIM                                               $35, 'name'
         45        OP_DATA                                                  ~37
   12    46    > > JMP                                                      ->17
         47    >   FE_FREE                                                  $14
   26    48        INIT_FCALL                                               'print_r'
         49        SEND_VAR                                                 !1
         50        DO_ICALL                                                 
         51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.4 ms | 1400 KiB | 15 Q