3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '2DAYSALEGATE_PG1.jpg', '2DAYSALEGATE_PG2.jpg', '722_PG1.jpg', 'PW_PG2_COKE_A.jpg', 'PW_PG3_COKE_A.jpg', 'PWBY4_DELI-1.jpg' ]; function sortArrayOfStrings($array): array { array_multisort( str_replace('_', ' ', $array), SORT_NATURAL, $array ); return $array; } function dimaSort($array): array { usort($array, function ($a, $b) { $aTemp = str_replace('_', '0', $a); $bTemp = str_replace('_', '0', $b); return strcmp($aTemp,$bTemp); }); return $array; } var_export([ sortArrayOfStrings($array), dimaSort($array) ]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDjdN
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   34     1        INIT_FCALL                                               'var_export'
   35     2        INIT_FCALL                                               'sortarrayofstrings'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        INIT_ARRAY                                       ~3      $2
   36     6        INIT_FCALL                                               'dimasort'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $4      
          9        ADD_ARRAY_ELEMENT                                ~3      $4
         10        SEND_VAL                                                 ~3
   34    11        DO_ICALL                                                 
   37    12      > RETURN                                                   1

Function sortarrayofstrings:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDjdN
function name:  sortArrayOfStrings
number of ops:  15
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'array_multisort'
   16     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '_'
          4        SEND_VAL                                                 '+'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAL                                                 $1
   17     8        SEND_VAL                                                 6
   18     9        SEND_REF                                                 !0
   15    10        DO_ICALL                                                 
   20    11        VERIFY_RETURN_TYPE                                       !0
         12      > RETURN                                                   !0
   21    13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null

End of function sortarrayofstrings

Function dimasort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDjdN
function name:  dimaSort
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   29     4        SEND_VAL                                                 ~1
   25     5        DO_ICALL                                                 
   30     6        VERIFY_RETURN_TYPE                                       !0
          7      > RETURN                                                   !0
   31     8*       VERIFY_RETURN_TYPE                                       
          9*     > 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/jDjdN
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $a, !1 = $b, !2 = $aTemp, !3 = $bTemp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '_'
          4        SEND_VAL                                                 '0'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !2, $4
   27     8        INIT_FCALL                                               'str_replace'
          9        SEND_VAL                                                 '_'
         10        SEND_VAL                                                 '0'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !3, $6
   28    14        INIT_FCALL                                               'strcmp'
         15        SEND_VAR                                                 !2
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $8      
         18      > RETURN                                                   $8
   29    19*     > RETURN                                                   null

End of Dynamic Function 0

End of function dimasort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.06 ms | 1079 KiB | 20 Q