3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 125 => '3110 - with a string', 128 => '3009 - keep a string', 126 => '3111 - a string', 121 => '3114 - be a string', 122 => '3113 - last string', ]; function cmp($a, $b) { return strcmp(trim(explode('-',$a)[1]) ,trim(explode('-',$b)[1])); } usort($array, "cmp"); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEdmt
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   18     1        INIT_FCALL                                                   'usort'
          2        SEND_REF                                                     !0
          3        SEND_VAL                                                     'cmp'
          4        DO_ICALL                                                     
   20     5        INIT_FCALL                                                   'print_r'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function cmp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEdmt
function name:  cmp
number of ops:  20
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   14     2        INIT_FCALL                                                   'strcmp'
          3        INIT_FCALL                                                   'explode'
          4        SEND_VAL                                                     '-'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $2      
          7        FETCH_DIM_R                                          ~3      $2, 1
          8        FRAMELESS_ICALL_1                trim                ~4      ~3
          9        SEND_VAL                                                     ~4
         10        INIT_FCALL                                                   'explode'
         11        SEND_VAL                                                     '-'
         12        SEND_VAR                                                     !1
         13        DO_ICALL                                             $5      
         14        FETCH_DIM_R                                          ~6      $5, 1
         15        FRAMELESS_ICALL_1                trim                ~7      ~6
         16        SEND_VAL                                                     ~7
         17        DO_ICALL                                             $8      
         18      > RETURN                                                       $8
   15    19*     > RETURN                                                       null

End of function cmp

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.52 ms | 1884 KiB | 17 Q