3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 2 => [ 'position' => 0, 'children' => [ 3 => ['position' => "375"], 5 => ['position' => "44"], 6 => ['position' => "567"], 9 => [ 'position' => "12", 'children' => [ 74 => ['position' => "2"], 76 => ['position' => "3"], 77 => ['position' => "1"], ] ], 62 => ['position' => "34"], 63 => ['position' => "11"], 66 => ['position' => "114"], 74 => ['position' => "912"], 76 => ['position' => "4564"], ] ] ]; function recur(&$data): void { uasort($data, fn($a, $b) => $a['position'] <=> $b['position']); foreach($data as &$value){ if (isset($value['children'])) { recur($value['children']); } } } recur($array); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKi1A
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   37     1        INIT_FCALL                                                   'recur'
          2        SEND_REF                                                     !0
          3        DO_FCALL                                          0          
   38     4        INIT_FCALL                                                   'var_export'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                                     
          7      > RETURN                                                       1

Function recur:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 126) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/uKi1A
function name:  recur
number of ops:  18
compiled vars:  !0 = $data, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   RECV                                                 !0      
   30     1        INIT_FCALL                                                   'uasort'
          2        SEND_REF                                                     !0
          3        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          4        SEND_VAL                                                     ~2
          5        DO_ICALL                                                     
   31     6      > FE_RESET_RW                                          $4      !0, ->16
          7    > > FE_FETCH_RW                                                  $4, !1, ->16
   32     8    >   ISSET_ISEMPTY_DIM_OBJ                             0          !1, 'children'
          9      > JMPZ                                                         ~5, ->15
   33    10    >   INIT_FCALL_BY_NAME                                           'recur'
         11        CHECK_FUNC_ARG                                               
         12        FETCH_DIM_FUNC_ARG                                   $6      !1, 'children'
         13        SEND_FUNC_ARG                                                $6
         14        DO_FCALL                                          0          
   31    15    > > JMP                                                          ->7
         16    >   FE_FREE                                                      $4
   36    17      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKi1A
function name:  {closure:recur():30}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        FETCH_DIM_R                                          ~2      !0, 'position'
          3        FETCH_DIM_R                                          ~3      !1, 'position'
          4        SPACESHIP                                            ~4      ~2, ~3
          5      > RETURN                                                       ~4
          6*     > RETURN                                                       null

End of Dynamic Function 0

End of function recur

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.26 ms | 1910 KiB | 16 Q