3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ ['name' => 'Dr. Hugo Lopez', 'duty' => 'Anesthesiologist', 'link' => ''], ['name' => 'Dr. Dario Garin', 'duty' => 'Orthopedic Specialist', 'link' => 'dr-dario-garin.php'], ['name' => 'Dr. Maclovio YaƱez', 'duty' => 'Plastic Surgeon', 'link' => ''], ['name' => 'Melissa Bracker', 'duty' => 'Patient Liaison', 'link' => ''], ['name' => 'Dr. Diego Guzman', 'duty' => 'Cardiologist', 'link' => ''], ['name' => 'Ivan Arafat', 'duty' => 'Accountant', 'link' => ''], ['name' => 'Jorge Fernandez', 'duty' => 'Hospital Administrator', 'link' => ''], ]; $lookup = array_flip(['Hospital Administrator', 'Plastic Surgeon', 'Orthopedic Specialist']); $fallback = count($lookup); usort($array, function ($a, $b) use ($lookup, $fallback) { return ($lookup[$a['duty']] ?? $fallback) <=> ($lookup[$b['duty']] ?? $fallback); }); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9h4YX
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array, !1 = $lookup, !2 = $fallback
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   13     1        INIT_FCALL                                                   'array_flip'
          2        SEND_VAL                                                     <array>
          3        DO_ICALL                                             $4      
          4        ASSIGN                                                       !1, $4
   14     5        COUNT                                                ~6      !1
          6        ASSIGN                                                       !2, ~6
   16     7        INIT_FCALL                                                   'usort'
          8        SEND_REF                                                     !0
          9        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
         10        BIND_LEXICAL                                                 ~8, !1
         11        BIND_LEXICAL                                                 ~8, !2
   18    12        SEND_VAL                                                     ~8
   16    13        DO_ICALL                                                     
   19    14        INIT_FCALL                                                   'var_export'
         15        SEND_VAR                                                     !0
         16        DO_ICALL                                                     
         17      > 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/9h4YX
function name:  {closure:/in/9h4YX:16}
number of ops:  15
compiled vars:  !0 = $a, !1 = $b, !2 = $lookup, !3 = $fallback
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
          3        BIND_STATIC                                                  !3
   17     4        FETCH_DIM_R                                          ~4      !0, 'duty'
          5        FETCH_DIM_IS                                         ~5      !2, ~4
          6        COALESCE                                             ~6      ~5
          7        QM_ASSIGN                                            ~6      !3
          8        FETCH_DIM_R                                          ~7      !1, 'duty'
          9        FETCH_DIM_IS                                         ~8      !2, ~7
         10        COALESCE                                             ~9      ~8
         11        QM_ASSIGN                                            ~9      !3
         12        SPACESHIP                                            ~10     ~6, ~9
         13      > RETURN                                                       ~10
   18    14*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.7 ms | 2357 KiB | 16 Q