3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('MY_ORDER', [0 => 2, 1 => 3, 2 => 0, 8 => 1]); function keyfn($v) { echo "called for $v\n"; return MY_ORDER[$v]; } $array = [2, 2, 2, 1, 1, 0, 0, 8]; array_multisort(array_map('keyfn', $array), $array); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dMtPA
function name:  (null)
number of ops:  17
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'MY_ORDER'
          2        SEND_VAL                                                 <array>
          3        DO_ICALL                                                 
    9     4        ASSIGN                                                   !0, <array>
   11     5        INIT_FCALL                                               'array_multisort'
          6        INIT_FCALL                                               'array_map'
          7        SEND_VAL                                                 'keyfn'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10        SEND_VAL                                                 $3
         11        SEND_REF                                                 !0
         12        DO_ICALL                                                 
   12    13        INIT_FCALL                                               'var_export'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function keyfn:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dMtPA
function name:  keyfn
number of ops:  9
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ROPE_INIT                                     3  ~2      'called+for+'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        ECHO                                                     ~1
    6     5        FETCH_CONSTANT                                   ~4      'MY_ORDER'
          6        FETCH_DIM_R                                      ~5      ~4, !0
          7      > RETURN                                                   ~5
    7     8*     > RETURN                                                   null

End of function keyfn

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.49 ms | 1395 KiB | 21 Q