3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array('person f','person c','person g','person a','person d','person e'); $last = array('person a','person c','person g'); usort($data,function($a,$b) use($last){ return in_array($a,$last) <=> in_array($b,$last) //sort if in $last ?: $a <=> $b; //sort alphabetically }); var_export($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B3G8s
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    7     2        INIT_FCALL                                               'usort'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   10     6        SEND_VAL                                                 ~4
    7     7        DO_ICALL                                                 
   12     8        INIT_FCALL                                               'var_export'
          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/B3G8s
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $a, !1 = $b, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    8     3        INIT_FCALL                                               'in_array'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $3      
          7        INIT_FCALL                                               'in_array'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $4      
         11        SPACESHIP                                        ~5      $3, $4
         12        JMP_SET                                          ~6      ~5, ->15
    9    13        SPACESHIP                                        ~7      !0, !1
         14        QM_ASSIGN                                        ~6      ~7
         15      > RETURN                                                   ~6
   10    16*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.42 ms | 1016 KiB | 16 Q