3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( "item1"=>"1", "item2"=>"3", "item3"=>"5", "item4"=>"2", "item5"=>"4" ); $sortingArr = array("5","4","3","2","1"); $keys = array_flip($sortingArr); usort($data, function ($a, $b) use ($keys) { return $keys[$a] > $keys[$b] ? 1 : -1; }); print_r($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/75cnu
function name:  (null)
number of ops:  16
compiled vars:  !0 = $data, !1 = $sortingArr, !2 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   13     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   15     6        INIT_FCALL                                               'usort'
          7        SEND_REF                                                 !0
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F75cnu%3A15%240'
          9        BIND_LEXICAL                                             ~7, !2
   17    10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
   19    12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F75cnu%3A15%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/75cnu
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $a, !1 = $b, !2 = $keys
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      !2, !0
          4        FETCH_DIM_R                                      ~4      !2, !1
          5        IS_SMALLER                                               ~4, ~3
          6      > JMPZ                                                     ~5, ->9
          7    >   QM_ASSIGN                                        ~6      1
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~6      -1
         10    > > RETURN                                                   ~6
   17    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F75cnu%3A15%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.4 ms | 1396 KiB | 19 Q