3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sortLikeThis = [ '5', '3', '7', '1' ]; $unsorted = [ [ 'sort' => '7', 'name' => 'Test', ], [ 'sort' => '1', 'name' => 'Test 2', ], [ 'sort' => '3', 'name' => 'Test 3', ], [ 'sort' => '5', 'name' => 'Test 4', ], [ 'sort' => '7', 'name' => 'Test 4', ], ]; usort($unsorted, function($x, $y) use ($sortLikeThis) { return array_search($x['sort'], $sortLikeThis) - array_search($y['sort'], $sortLikeThis); }); var_dump($unsorted);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nZ0CJ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $sortLikeThis, !1 = $unsorted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   32     2        INIT_FCALL                                               'usort'
          3        SEND_REF                                                 !1
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FnZ0CJ%3A32%240'
          5        BIND_LEXICAL                                             ~4, !0
   35     6        SEND_VAL                                                 ~4
          7        DO_ICALL                                                 
   38     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FnZ0CJ%3A32%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nZ0CJ
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $x, !1 = $y, !2 = $sortLikeThis
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   34     3        INIT_FCALL                                               'array_search'
          4        FETCH_DIM_R                                      ~3      !0, 'sort'
          5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $4      
          8        INIT_FCALL                                               'array_search'
          9        FETCH_DIM_R                                      ~5      !1, 'sort'
         10        SEND_VAL                                                 ~5
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $6      
         13        SUB                                              ~7      $4, $6
         14      > RETURN                                                   ~7
   35    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FnZ0CJ%3A32%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.7 ms | 1401 KiB | 19 Q