3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ 'id' => 5, 'name' => 'Item 5', 'all_parents' => [ 'id' => 4, 'name' => 'Item 4', 'all_parents' => [ 'id' => 3, 'name' => 'Item 3', 'all_parents' => [ 'id' => 2, 'name' => 'Item 2', 'all_parents' => [ 'id' => 1, 'name' => 'Item 1', 'all_parents' => null ] ] ] ] ]; class Recursing { public function generateBreadcrumb($structure): array { return array_merge( empty($structure['all_parents']) ? [] : $this->generateBreadcrumb($structure['all_parents']), [['id' => $structure['id'], 'name' => $structure['name']]] ); } } $test = new Recursing; var_export($test->generateBreadcrumb($arr));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qqLMo
function name:  (null)
number of ops:  11
compiled vars:  !0 = $arr, !1 = $test
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   36     1        NEW                                                  $3      'Recursing'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $3
   37     4        INIT_FCALL                                                   'var_export'
          5        INIT_METHOD_CALL                                             !1, 'generateBreadcrumb'
          6        SEND_VAR_EX                                                  !0
          7        DO_FCALL                                          0  $6      
          8        SEND_VAR                                                     $6
          9        DO_ICALL                                                     
         10      > RETURN                                                       1

Class Recursing:
Function generatebreadcrumb:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qqLMo
function name:  generateBreadcrumb
number of ops:  24
compiled vars:  !0 = $structure
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
   29     1        INIT_FCALL                                                   'array_merge'
   30     2        ISSET_ISEMPTY_DIM_OBJ                             1          !0, 'all_parents'
          3      > JMPZ                                                         ~1, ->6
          4    >   QM_ASSIGN                                            ~2      <array>
          5      > JMP                                                          ->12
          6    >   INIT_METHOD_CALL                                             'generateBreadcrumb'
          7        CHECK_FUNC_ARG                                               
          8        FETCH_DIM_FUNC_ARG                                   $3      !0, 'all_parents'
          9        SEND_FUNC_ARG                                                $3
         10        DO_FCALL                                          0  $4      
         11        QM_ASSIGN                                            ~2      $4
         12    >   SEND_VAL                                                     ~2
   31    13        FETCH_DIM_R                                          ~5      !0, 'id'
         14        INIT_ARRAY                                           ~6      ~5, 'id'
         15        FETCH_DIM_R                                          ~7      !0, 'name'
         16        ADD_ARRAY_ELEMENT                                    ~6      ~7, 'name'
         17        INIT_ARRAY                                           ~8      ~6
         18        SEND_VAL                                                     ~8
   29    19        DO_ICALL                                             $9      
   31    20        VERIFY_RETURN_TYPE                                           $9
         21      > RETURN                                                       $9
   33    22*       VERIFY_RETURN_TYPE                                           
         23*     > RETURN                                                       null

End of function generatebreadcrumb

End of class Recursing.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.01 ms | 1979 KiB | 15 Q