3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', ]; function multisort($array) { array_multisort(array_map('strlen', $array), SORT_DESC, $array); printf( "Total strlen() calls: %d\n%s\n---\n", count($array), var_export($array, true) ); } function usersort($array) { usort( $array, function($a, $b) { echo "strlen() called twice\n"; return strlen($b) <=> strlen($a); } ); var_export($array); echo "\n---\n"; } multisort($array); usersort($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aVeoE
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   36     1        INIT_FCALL                                                   'multisort'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0          
   37     4        INIT_FCALL                                                   'usersort'
          5        SEND_VAR                                                     !0
          6        DO_FCALL                                          0          
          7      > RETURN                                                       1

Function multisort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aVeoE
function name:  multisort
number of ops:  21
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
   16     1        INIT_FCALL                                                   'array_multisort'
          2        INIT_FCALL                                                   'array_map'
          3        SEND_VAL                                                     'strlen'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $1      
          6        SEND_VAL                                                     $1
          7        SEND_VAL                                                     3
          8        SEND_REF                                                     !0
          9        DO_ICALL                                                     
   17    10        INIT_FCALL                                                   'printf'
   18    11        SEND_VAL                                                     'Total+strlen%28%29+calls%3A+%25d%0A%25s%0A---%0A'
   19    12        COUNT                                                ~3      !0
         13        SEND_VAL                                                     ~3
   20    14        INIT_FCALL                                                   'var_export'
         15        SEND_VAR                                                     !0
         16        SEND_VAL                                                     <true>
         17        DO_ICALL                                             $4      
         18        SEND_VAR                                                     $4
   17    19        DO_ICALL                                                     
   22    20      > RETURN                                                       null

End of function multisort

Function usersort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aVeoE
function name:  usersort
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   RECV                                                 !0      
   25     1        INIT_FCALL                                                   'usort'
   26     2        SEND_REF                                                     !0
   27     3        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
   30     4        SEND_VAL                                                     ~1
   25     5        DO_ICALL                                                     
   32     6        INIT_FCALL                                                   'var_export'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                                     
   33     9        ECHO                                                         '%0A---%0A'
   34    10      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aVeoE
function name:  {closure:usersort():27}
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   28     2        ECHO                                                         'strlen%28%29+called+twice%0A'
   29     3        STRLEN                                               ~2      !1
          4        STRLEN                                               ~3      !0
          5        SPACESHIP                                            ~4      ~2, ~3
          6      > RETURN                                                       ~4
   30     7*     > RETURN                                                       null

End of Dynamic Function 0

End of function usersort

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.01 ms | 2057 KiB | 20 Q