3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['id' => '111', 'value' => 'abc'], ['id' => '100', 'value' => 'abc'], ['id' => '132', 'value' => 'abc'], ['id' => '222', 'value' => 'abc'], ['id' => '112', 'value' => 'abc'], ['id' => '200', 'value' => 'abc'] ]; $idPriorities = array_flip(['112', '111', '132', '100']); $idOutlier = count($idPriorities); usort( $array, function($a, $b) use ($idPriorities, $idOutlier) { return ($idPriorities[$a['id']] ?? $idOutlier) <=> ($idPriorities[$b['id']] ?? $idOutlier); } ); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fh5nq
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array, !1 = $idPriorities, !2 = $idOutlier
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'array_flip'
          2        SEND_VAL                                                 <array>
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   13     5        COUNT                                            ~6      !1
          6        ASSIGN                                                   !2, ~6
   15     7        INIT_FCALL                                               'usort'
   16     8        SEND_REF                                                 !0
   17     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFh5nq%3A17%240'
         10        BIND_LEXICAL                                             ~8, !1
         11        BIND_LEXICAL                                             ~8, !2
   19    12        SEND_VAL                                                 ~8
         13        DO_ICALL                                                 
   22    14        INIT_FCALL                                               'var_export'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FFh5nq%3A17%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fh5nq
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $a, !1 = $b, !2 = $idPriorities, !3 = $idOutlier
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   18     4        FETCH_DIM_R                                      ~4      !0, 'id'
          5        FETCH_DIM_IS                                     ~5      !2, ~4
          6        COALESCE                                         ~6      ~5
          7        QM_ASSIGN                                        ~6      !3
          8        FETCH_DIM_R                                      ~7      !1, 'id'
          9        FETCH_DIM_IS                                     ~8      !2, ~7
         10        COALESCE                                         ~9      ~8
         11        QM_ASSIGN                                        ~9      !3
         12        SPACESHIP                                        ~10     ~6, ~9
         13      > RETURN                                                   ~10
   19    14*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FFh5nq%3A17%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.3 ms | 1401 KiB | 19 Q