3v4l.org

run code in 300+ 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) { $aName = array_reverse(preg_match('~^((?:[a-z]+\.)?) ?(\S+) (.+)~i', $a['name'], $out) ? $out : ['', '', '']); $bName = array_reverse(preg_match('~^((?:[a-z]+\.)?) ?(\S+) (.+)~i', $b['name'], $out) ? $out : ['', '', '']); return [$lookup[$a['duty']] ?? $fallback, ...$aName] <=> [$lookup[$b['duty']] ?? $fallback, ...$bName]; }); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LRuD4
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
   22    12        SEND_VAL                                                 ~8
   16    13        DO_ICALL                                                 
   23    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
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
Branch analysis from position: 28
filename:       /in/LRuD4
function name:  {closure}
number of ops:  47
compiled vars:  !0 = $a, !1 = $b, !2 = $lookup, !3 = $fallback, !4 = $aName, !5 = $out, !6 = $bName
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        INIT_FCALL                                               'array_reverse'
          5        INIT_FCALL                                               'preg_match'
          6        SEND_VAL                                                 '%7E%5E%28%28%3F%3A%5Ba-z%5D%2B%5C.%29%3F%29+%3F%28%5CS%2B%29+%28.%2B%29%7Ei'
          7        FETCH_DIM_R                                      ~7      !0, 'name'
          8        SEND_VAL                                                 ~7
          9        SEND_REF                                                 !5
         10        DO_ICALL                                         $8      
         11      > JMPZ                                                     $8, ->14
         12    >   QM_ASSIGN                                        ~9      !5
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~9      <array>
         15    >   SEND_VAL                                                 ~9
         16        DO_ICALL                                         $10     
         17        ASSIGN                                                   !4, $10
   18    18        INIT_FCALL                                               'array_reverse'
         19        INIT_FCALL                                               'preg_match'
         20        SEND_VAL                                                 '%7E%5E%28%28%3F%3A%5Ba-z%5D%2B%5C.%29%3F%29+%3F%28%5CS%2B%29+%28.%2B%29%7Ei'
         21        FETCH_DIM_R                                      ~12     !1, 'name'
         22        SEND_VAL                                                 ~12
         23        SEND_REF                                                 !5
         24        DO_ICALL                                         $13     
         25      > JMPZ                                                     $13, ->28
         26    >   QM_ASSIGN                                        ~14     !5
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~14     <array>
         29    >   SEND_VAL                                                 ~14
         30        DO_ICALL                                         $15     
         31        ASSIGN                                                   !6, $15
   19    32        FETCH_DIM_R                                      ~17     !0, 'duty'
         33        FETCH_DIM_IS                                     ~18     !2, ~17
         34        COALESCE                                         ~19     ~18
         35        QM_ASSIGN                                        ~19     !3
         36        INIT_ARRAY                                       ~20     ~19
         37        ADD_ARRAY_UNPACK                                 ~20     !4
   21    38        FETCH_DIM_R                                      ~21     !1, 'duty'
         39        FETCH_DIM_IS                                     ~22     !2, ~21
         40        COALESCE                                         ~23     ~22
         41        QM_ASSIGN                                        ~23     !3
         42        INIT_ARRAY                                       ~24     ~23
         43        ADD_ARRAY_UNPACK                                 ~24     !6
         44        SPACESHIP                                        ~25     ~20, ~24
         45      > RETURN                                                   ~25
   22    46*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.25 ms | 1079 KiB | 18 Q