3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'name' => 'Foo', 'children' => [ [ 'name' => 'B', 'children' => [] ], [ 'name' => 'A', 'children' => [] ] ] ], [ 'name' => 'Bar', 'children' => [ [ 'name' => 'Z', 'children' => [] ], [ 'name' => 'X', 'children' => [] ], [ 'name' => 'Y', 'children' => [] ] ] ] ]; $name = null; usort($array, $f = function(&$x, &$y) use (&$f, &$name){ $myName = $name; $name = $x['name']; usort($x['children'], $f); $name = $y['name']; usort($y['children'], $f); var_dump($myName, $x['children']); return strcasecmp($x['name'], $y['name']); }); var_dump($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RWnG1
function name:  (null)
number of ops:  14
compiled vars:  !0 = $array, !1 = $name, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        ASSIGN                                                   !1, null
   38     2        INIT_FCALL                                               'usort'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FRWnG1%3A38%240'
          5        BIND_LEXICAL                                             ~5, !2
          6        BIND_LEXICAL                                             ~5, !1
          7        ASSIGN                                           ~6      !2, ~5
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                                 
   50    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FRWnG1%3A38%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RWnG1
function name:  {closure}
number of ops:  32
compiled vars:  !0 = $x, !1 = $y, !2 = $f, !3 = $name, !4 = $myName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   39     4        ASSIGN                                                   !4, !3
   41     5        FETCH_DIM_R                                      ~6      !0, 'name'
          6        ASSIGN                                                   !3, ~6
   42     7        INIT_FCALL                                               'usort'
          8        FETCH_DIM_W                                      $8      !0, 'children'
          9        SEND_REF                                                 $8
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   43    12        FETCH_DIM_R                                      ~10     !1, 'name'
         13        ASSIGN                                                   !3, ~10
   44    14        INIT_FCALL                                               'usort'
         15        FETCH_DIM_W                                      $12     !1, 'children'
         16        SEND_REF                                                 $12
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   46    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !4
         21        FETCH_DIM_R                                      ~14     !0, 'children'
         22        SEND_VAL                                                 ~14
         23        DO_ICALL                                                 
   47    24        INIT_FCALL                                               'strcasecmp'
         25        FETCH_DIM_R                                      ~16     !0, 'name'
         26        SEND_VAL                                                 ~16
         27        FETCH_DIM_R                                      ~17     !1, 'name'
         28        SEND_VAL                                                 ~17
         29        DO_ICALL                                         $18     
         30      > RETURN                                                   $18
   48    31*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FRWnG1%3A38%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.17 ms | 1400 KiB | 19 Q