3v4l.org

run code in 500+ PHP versions simultaneously
<?php $rows = [ ['ID' => 188, 'zip_code' => 60022, 'approved' => 0], ['ID' => 124, 'zip_code' => 60002, 'approved' => 0], ['ID' => 138, 'zip_code' => 60007, 'approved' => 1], ['ID' => 114, 'zip_code' => 60007, 'approved' => 1], ['ID' => 105, 'zip_code' => 60003, 'approved' => 0], ['ID' => 104, 'zip_code' => 60002, 'approved' => 1], ['ID' => 199, 'zip_code' => 60199, 'approved' => 0], ['ID' => 106, 'zip_code' => 60001, 'approved' => 0], ['ID' => 184, 'zip_code' => 60022, 'approved' => 1], ['ID' => 103, 'zip_code' => 60007, 'approved' => 0], ]; $priorityZips = array_flip([60007, 60001, 60003, 60002]); $priorityCount = count($priorityZips); usort($rows, function($a, $b) use ($priorityZips, $priorityCount) { return [ $priorityZips[$a['zip_code']] ?? $priorityCount, $a['zip_code'], $b['approved'] ] <=> [ $priorityZips[$b['zip_code']] ?? $priorityCount, $b['zip_code'], $a['approved'] ]; }); var_export($rows);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1QlTL
function name:  (null)
number of ops:  18
compiled vars:  !0 = $rows, !1 = $priorityZips, !2 = $priorityCount
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   16     1        INIT_FCALL                                                   'array_flip'
          2        SEND_VAL                                                     <array>
          3        DO_ICALL                                             $4      
          4        ASSIGN                                                       !1, $4
   17     5        COUNT                                                ~6      !1
          6        ASSIGN                                                       !2, ~6
   19     7        INIT_FCALL                                                   'usort'
          8        SEND_REF                                                     !0
          9        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
         10        BIND_LEXICAL                                                 ~8, !1
         11        BIND_LEXICAL                                                 ~8, !2
   31    12        SEND_VAL                                                     ~8
   19    13        DO_ICALL                                                     
   33    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/1QlTL
function name:  {closure:/in/1QlTL:19}
number of ops:  25
compiled vars:  !0 = $a, !1 = $b, !2 = $priorityZips, !3 = $priorityCount
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
          3        BIND_STATIC                                                  !3
   21     4        FETCH_DIM_R                                          ~4      !0, 'zip_code'
          5        FETCH_DIM_IS                                         ~5      !2, ~4
          6        COALESCE                                             ~6      ~5
          7        QM_ASSIGN                                            ~6      !3
          8        INIT_ARRAY                                           ~7      ~6
   22     9        FETCH_DIM_R                                          ~8      !0, 'zip_code'
         10        ADD_ARRAY_ELEMENT                                    ~7      ~8
   23    11        FETCH_DIM_R                                          ~9      !1, 'approved'
         12        ADD_ARRAY_ELEMENT                                    ~7      ~9
   27    13        FETCH_DIM_R                                          ~10     !1, 'zip_code'
         14        FETCH_DIM_IS                                         ~11     !2, ~10
         15        COALESCE                                             ~12     ~11
         16        QM_ASSIGN                                            ~12     !3
         17        INIT_ARRAY                                           ~13     ~12
   28    18        FETCH_DIM_R                                          ~14     !1, 'zip_code'
         19        ADD_ARRAY_ELEMENT                                    ~13     ~14
   29    20        FETCH_DIM_R                                          ~15     !0, 'approved'
         21        ADD_ARRAY_ELEMENT                                    ~13     ~15
         22        SPACESHIP                                            ~16     ~7, ~13
         23      > RETURN                                                       ~16
   31    24*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.55 ms | 2220 KiB | 16 Q