3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ [ "id" => 1, "recipient" => "User", "userName" => "Max Mustermann", "locationName" => "Test Location" ], [ "id" => 2, "recipient" => "Location", "userName" => "Susi Mustermann", "locationName" => "Another Location" ], [ "id" => 3, "recipient" => "Location", "userName" => "Susi Mustermann", "locationName" => "Wow Much Location" ], [ "id" => 4, "recipient" => "User", "userName" => "Fritz Kalkbrenner", "locationName" => "Good Music" ], [ "id" => 5, "recipient" => "Location", "userName" => "Paul Kalkbrenner", "locationName" => null ], ]; usort($array,function($a,$b){ $sort2key = strtolower($a['recipient']).'Name'; return $a['recipient'] <=> $b['recipient'] ?: is_null($a['locationName']) <=> is_null($b['locationName']) ?: $a[$sort2key] <=> $b[$sort2key]; }); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L6cBn
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   36     1        INIT_FCALL                                                   'usort'
          2        SEND_REF                                                     !0
          3        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
   41     4        SEND_VAL                                                     ~2
   36     5        DO_ICALL                                                     
   43     6        INIT_FCALL                                                   'var_export'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                                     
          9      > 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/L6cBn
function name:  {closure:/in/L6cBn:36}
number of ops:  25
compiled vars:  !0 = $a, !1 = $b, !2 = $sort2key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   37     2        INIT_FCALL                                                   'strtolower'
          3        FETCH_DIM_R                                          ~3      !0, 'recipient'
          4        SEND_VAL                                                     ~3
          5        DO_ICALL                                             $4      
          6        CONCAT                                               ~5      $4, 'Name'
          7        ASSIGN                                                       !2, ~5
   38     8        FETCH_DIM_R                                          ~7      !0, 'recipient'
          9        FETCH_DIM_R                                          ~8      !1, 'recipient'
         10        SPACESHIP                                            ~9      ~7, ~8
         11        JMP_SET                                              ~10     ~9, ->18
   39    12        FETCH_DIM_R                                          ~11     !0, 'locationName'
         13        TYPE_CHECK                                        2  ~12     ~11
         14        FETCH_DIM_R                                          ~13     !1, 'locationName'
         15        TYPE_CHECK                                        2  ~14     ~13
         16        SPACESHIP                                            ~15     ~12, ~14
         17        QM_ASSIGN                                            ~10     ~15
         18        JMP_SET                                              ~16     ~10, ->23
   40    19        FETCH_DIM_R                                          ~17     !0, !2
         20        FETCH_DIM_R                                          ~18     !1, !2
         21        SPACESHIP                                            ~19     ~17, ~18
         22        QM_ASSIGN                                            ~16     ~19
         23      > RETURN                                                       ~16
   41    24*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
210.51 ms | 1986 KiB | 16 Q