3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ 1 => [ 'name' => 'EC567', 'type' => 'B3000', 'value' => '4DFYU', ], 2 => [ 'name' => '1C527', 'type' => 'B3UI0', 'value' => '4DMNU', ] ]; $order = ['RD678', '9O0PM', '1C527', 'EC567']; usort($arr, fn(array $a, array $b): int => array_search($a['name'], $order) <=> array_search($b['name'], $order) ); var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X9vDW
function name:  (null)
number of ops:  12
compiled vars:  !0 = $arr, !1 = $order
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   15     1        ASSIGN                                                       !1, <array>
   17     2        INIT_FCALL                                                   'usort'
          3        SEND_REF                                                     !0
          4        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          5        BIND_LEXICAL                                                 ~4, !1
   19     6        SEND_VAL                                                     ~4
   17     7        DO_ICALL                                                     
   22     8        INIT_FCALL                                                   'var_dump'
          9        SEND_VAR                                                     !0
         10        DO_ICALL                                                     
         11      > 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/X9vDW
function name:  {closure:/in/X9vDW:17}
number of ops:  18
compiled vars:  !0 = $a, !1 = $b, !2 = $order
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   18     3        INIT_FCALL                                                   'array_search'
          4        FETCH_DIM_R                                          ~3      !0, 'name'
          5        SEND_VAL                                                     ~3
          6        SEND_VAR                                                     !2
          7        DO_ICALL                                             $4      
          8        INIT_FCALL                                                   'array_search'
          9        FETCH_DIM_R                                          ~5      !1, 'name'
         10        SEND_VAL                                                     ~5
         11        SEND_VAR                                                     !2
         12        DO_ICALL                                             $6      
         13        SPACESHIP                                            ~7      $4, $6
         14        VERIFY_RETURN_TYPE                                           ~7
         15      > RETURN                                                       ~7
   19    16*       VERIFY_RETURN_TYPE                                           
         17*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
149.82 ms | 1933 KiB | 16 Q