3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ ['id' => 7867867, 'animal' => 'Dog'], ['id' => 3452342, 'animal' => 'Lion'], ['id' => 1231233, 'animal' => 'Lion'], ['id' => 5867867, 'animal' => 'Dog'], ['id' => 1111111, 'animal' => 'Zeebra'], ['id' => 2222222, 'animal' => 'Cat'], ['id' => 3333333, 'animal' => 'Cat'], ['id' => 4444444, 'animal' => 'Zeebra'] ]; $priorities = array_flip(['Lion', 'Dog', 'Zeebra', 'Cat']); usort($array, function($a, $b) use ($priorities) { return $priorities[$a['animal']] <=> $priorities[$b['animal']]; }); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HOkbV
function name:  (null)
number of ops:  15
compiled vars:  !0 = $array, !1 = $priorities
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   13     1        INIT_FCALL                                                   'array_flip'
          2        SEND_VAL                                                     <array>
          3        DO_ICALL                                             $3      
          4        ASSIGN                                                       !1, $3
   15     5        INIT_FCALL                                                   'usort'
          6        SEND_REF                                                     !0
          7        DECLARE_LAMBDA_FUNCTION                              ~5      [0]
          8        BIND_LEXICAL                                                 ~5, !1
   17     9        SEND_VAL                                                     ~5
   15    10        DO_ICALL                                                     
   19    11        INIT_FCALL                                                   'var_export'
         12        SEND_VAR                                                     !0
         13        DO_ICALL                                                     
         14      > 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/HOkbV
function name:  {closure:/in/HOkbV:15}
number of ops:  10
compiled vars:  !0 = $a, !1 = $b, !2 = $priorities
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   16     3        FETCH_DIM_R                                          ~3      !0, 'animal'
          4        FETCH_DIM_R                                          ~4      !2, ~3
          5        FETCH_DIM_R                                          ~5      !1, 'animal'
          6        FETCH_DIM_R                                          ~6      !2, ~5
          7        SPACESHIP                                            ~7      ~4, ~6
          8      > RETURN                                                       ~7
   17     9*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.1 ms | 2254 KiB | 16 Q