3v4l.org

run code in 500+ 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:  12
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        FRAMELESS_ICALL_3                str_replace         ~1      '_', '+'
          3        OP_DATA                                                      !0
          4        SEND_VAL                                                     ~1
   17     5        SEND_VAL                                                     6
   18     6        SEND_REF                                                     !0
   15     7        DO_ICALL                                                     
   20     8        VERIFY_RETURN_TYPE                                           !0
          9      > RETURN                                                       !0
   21    10*       VERIFY_RETURN_TYPE                                           
         11*     > 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:dimaSort():25}
number of ops:  14
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        FRAMELESS_ICALL_3                str_replace         ~4      '_', '0'
          3        OP_DATA                                                      !0
          4        ASSIGN                                                       !2, ~4
   27     5        FRAMELESS_ICALL_3                str_replace         ~6      '_', '0'
          6        OP_DATA                                                      !1
          7        ASSIGN                                                       !3, ~6
   28     8        INIT_FCALL                                                   'strcmp'
          9        SEND_VAR                                                     !2
         10        SEND_VAR                                                     !3
         11        DO_ICALL                                             $8      
         12      > RETURN                                                       $8
   29    13*     > RETURN                                                       null

End of Dynamic Function 0

End of function dimasort

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.06 ms | 1936 KiB | 19 Q