3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['woid'=>'17643-2','schedule'=>'ASAP'], ['woid'=>'17643-1','schedule'=>'ASAP'], ['woid'=>'NC324-1','schedule'=>'ASAP'], ['woid'=>'17642-1','schedule'=>'URGENT'], ['woid'=>'NC323-1','schedule'=>'URGENT'], ['woid'=>'17644-1','schedule'=>'JAN'], ]; $order = ['URGENT','JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC','ASAP']; $order = array_flip($order); usort($array, function($a, $b) use ($order) { $aNC = strpos($a['woid'], 'NC') === 0; $bNC = strpos($b['woid'], 'NC') === 0; return ($bNC - $aNC) ?: ($order[$a['schedule']] - $order[$b['schedule']]) ?: strcmp($a['woid'], $b['woid']); }); var_dump($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WDD69
function name:  (null)
number of ops:  16
compiled vars:  !0 = $array, !1 = $order
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   13     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   15     6        INIT_FCALL                                               'usort'
          7        SEND_REF                                                 !0
          8        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          9        BIND_LEXICAL                                             ~6, !1
   19    10        SEND_VAL                                                 ~6
   15    11        DO_ICALL                                                 
   21    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > 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/WDD69
function name:  {closure}
number of ops:  35
compiled vars:  !0 = $a, !1 = $b, !2 = $order, !3 = $aNC, !4 = $bNC
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   16     3        INIT_FCALL                                               'strpos'
          4        FETCH_DIM_R                                      ~5      !0, 'woid'
          5        SEND_VAL                                                 ~5
          6        SEND_VAL                                                 'NC'
          7        DO_ICALL                                         $6      
          8        IS_IDENTICAL                                     ~7      $6, 0
          9        ASSIGN                                                   !3, ~7
   17    10        INIT_FCALL                                               'strpos'
         11        FETCH_DIM_R                                      ~9      !1, 'woid'
         12        SEND_VAL                                                 ~9
         13        SEND_VAL                                                 'NC'
         14        DO_ICALL                                         $10     
         15        IS_IDENTICAL                                     ~11     $10, 0
         16        ASSIGN                                                   !4, ~11
   18    17        SUB                                              ~13     !4, !3
         18        JMP_SET                                          ~14     ~13, ->25
         19        FETCH_DIM_R                                      ~15     !0, 'schedule'
         20        FETCH_DIM_R                                      ~16     !2, ~15
         21        FETCH_DIM_R                                      ~17     !1, 'schedule'
         22        FETCH_DIM_R                                      ~18     !2, ~17
         23        SUB                                              ~19     ~16, ~18
         24        QM_ASSIGN                                        ~14     ~19
         25        JMP_SET                                          ~20     ~14, ->33
         26        INIT_FCALL                                               'strcmp'
         27        FETCH_DIM_R                                      ~21     !0, 'woid'
         28        SEND_VAL                                                 ~21
         29        FETCH_DIM_R                                      ~22     !1, 'woid'
         30        SEND_VAL                                                 ~22
         31        DO_ICALL                                         $23     
         32        QM_ASSIGN                                        ~20     $23
         33      > RETURN                                                   ~20
   19    34*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
247.5 ms | 1079 KiB | 18 Q