3v4l.org

run code in 300+ PHP versions simultaneously
<?php $comments = [ 1 => ['content' => "The first comment", 'parent' => 0], 2 => ['content' => "The second comment", 'parent' => 0], 3 => ['content' => "Reply of first comment", 'parent' => 1], 4 => ['content' => "Another reply of first comemnt", 'parent' => 1], 5 => ['content' => "Reply of a reply of the first comment", 'parent' => 4] ]; foreach($comments as $id => &$c) { if (isset($comments[$c['parent']])) { $comments[$c['parent']]['comments'][$id] =& $c; unset($comments[$id]); } } var_dump($comments);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 14
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/Ck1VH
function name:  (null)
number of ops:  19
compiled vars:  !0 = $comments, !1 = $c, !2 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1      > FE_RESET_RW                                      $4      !0, ->14
          2    > > FE_FETCH_RW                                      ~5      $4, !1, ->14
          3    >   ASSIGN                                                   !2, ~5
   13     4        FETCH_DIM_R                                      ~7      !1, 'parent'
          5        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~7
          6      > JMPZ                                                     ~8, ->13
   14     7    >   FETCH_DIM_R                                      ~9      !1, 'parent'
          8        FETCH_DIM_W                                      $10     !0, ~9
          9        FETCH_DIM_W                                      $11     $10, 'comments'
         10        FETCH_DIM_W                                      $12     $11, !2
         11        ASSIGN_REF                                               $12, !1
   15    12        UNSET_DIM                                                !0, !2
   12    13    > > JMP                                                      ->2
         14    >   FE_FREE                                                  $4
   19    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.7 ms | 1395 KiB | 15 Q