3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['columnName' => 3], ['columnName' => 4], ['columnName' => 1], ['columnName' => 3], ['columnName' => 2], ['columnName' => 5] ]; $direction = 'asc'; $factor = $direction === 'desc' ? -1 : 1; $c = 'columnName'; usort( $array, fn($a, $b) => $factor * ($a[$c] <=> $b[$c]) ); var_export($array);
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 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M2d86
function name:  (null)
number of ops:  20
compiled vars:  !0 = $array, !1 = $direction, !2 = $factor, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, 'asc'
   13     2        IS_IDENTICAL                                             !1, 'desc'
          3      > JMPZ                                                     ~6, ->6
          4    >   QM_ASSIGN                                        ~7      -1
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~7      1
          7    >   ASSIGN                                                   !2, ~7
   14     8        ASSIGN                                                   !3, 'columnName'
   16     9        INIT_FCALL                                               'usort'
   17    10        SEND_REF                                                 !0
   18    11        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
         12        BIND_LEXICAL                                             ~10, !2
         13        BIND_LEXICAL                                             ~10, !3
   19    14        SEND_VAL                                                 ~10
   16    15        DO_ICALL                                                 
   21    16        INIT_FCALL                                               'var_export'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
         19      > RETURN                                                   1


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

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.79 ms | 1000 KiB | 15 Q