3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A1 { public function rows() { $a = array(); $a[] = array('parent_id' => 0, 'category_id' => 7, 'name' => 'id7'); $a[] = array('parent_id' => 0, 'category_id' => 8, 'name' => 'id8'); $a[] = array('parent_id' => 0, 'category_id' => 9, 'name' => 'id9'); $a[] = array('parent_id' => 7, 'category_id' => 10, 'name' => 'id10'); $a[] = array('parent_id' => 7, 'category_id' => 11, 'name' => 'id11'); $a[] = array('parent_id' => 8, 'category_id' => 12, 'name' => 'id12'); $a[] = array('parent_id' => 10, 'category_id' => 13, 'name' => 'id13'); return $a; } } $query = new A1; $categoryArray = array(); foreach($query->rows() as $row) { if(isset($categoryArray[$row['category_id']])) { $categoryArray[$row['parent_id']] = $row['category_id']; } else { $categoryArray[$row['parent_id']][$row['category_id']] = $row['name']; } } print_r($categoryArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 23
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/vDrjo
function name:  (null)
number of ops:  28
compiled vars:  !0 = $query, !1 = $categoryArray, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $3      'A1'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   19     3        ASSIGN                                                   !1, <array>
   21     4        INIT_METHOD_CALL                                         !0, 'rows'
          5        DO_FCALL                                      0  $7      
          6      > FE_RESET_R                                       $8      $7, ->23
          7    > > FE_FETCH_R                                               $8, !2, ->23
   22     8    >   FETCH_DIM_R                                      ~9      !2, 'category_id'
          9        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~9
         10      > JMPZ                                                     ~10, ->16
   23    11    >   FETCH_DIM_R                                      ~11     !2, 'parent_id'
         12        FETCH_DIM_R                                      ~13     !2, 'category_id'
         13        ASSIGN_DIM                                               !1, ~11
         14        OP_DATA                                                  ~13
         15      > JMP                                                      ->22
   25    16    >   FETCH_DIM_R                                      ~14     !2, 'parent_id'
         17        FETCH_DIM_R                                      ~16     !2, 'category_id'
         18        FETCH_DIM_R                                      ~18     !2, 'name'
         19        FETCH_DIM_W                                      $15     !1, ~14
         20        ASSIGN_DIM                                               $15, ~16
         21        OP_DATA                                                  ~18
   21    22    > > JMP                                                      ->7
         23    >   FE_FREE                                                  $8
   29    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class A1:
Function rows:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vDrjo
function name:  rows
number of ops:  17
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
    6     1        ASSIGN_DIM                                               !0
          2        OP_DATA                                                  <array>
    7     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  <array>
    8     5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  <array>
    9     7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  <array>
   10     9        ASSIGN_DIM                                               !0
         10        OP_DATA                                                  <array>
   11    11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  <array>
   12    13        ASSIGN_DIM                                               !0
         14        OP_DATA                                                  <array>
   14    15      > RETURN                                                   !0
   15    16*     > RETURN                                                   null

End of function rows

End of class A1.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.56 ms | 1400 KiB | 15 Q