3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ "A - 1.0 - Title Page.PDF", "A - 2.2 - Enlarged Floor Plans", "A - 2.1.0 - Structural Details.PDF", "E - 1.0 - Electrical Title Page.PDF", "A - 1.2 - Floor Plan.PDF", "P - 1.0 - Plumbing Title Page2.PDF", "A - 2.1.1 - Structural Details.PDF", "C - 1.0 - Civil Title Page.PDF", "M - 1.0 - Mechanical Title Page.PDF", "ESC - 1.0 - Erosion Control Plan.PDF", "P - 1.0 - Plumbing Title Page.PDF", ]; $priorities = array_flip(['A', 'ESC', 'C', 'M', 'E', 'P']); usort($arr, function ($a, $b) use ($priorities) { [$categoryA, $versionA, $nameA] = explode(' - ', $a, 3); [$categoryB, $versionB, $nameB] = explode(' - ', $b, 3); return $priorities[$categoryA] <=> $priorities[$categoryB] // priorities as first criteria ?: version_compare($versionB, $versionA) // then descending versions as second criteria ?: $nameA <=> $nameB; // then compare names ascending }); var_export($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GVb3I
function name:  (null)
number of ops:  15
compiled vars:  !0 = $arr, !1 = $priorities
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   17     1        INIT_FCALL                                                   'array_flip'
          2        SEND_VAL                                                     <array>
          3        DO_ICALL                                             $3      
          4        ASSIGN                                                       !1, $3
   19     5        INIT_FCALL                                                   'usort'
          6        SEND_REF                                                     !0
          7        DECLARE_LAMBDA_FUNCTION                              ~5      [0]
          8        BIND_LEXICAL                                                 ~5, !1
   26     9        SEND_VAL                                                     ~5
   19    10        DO_ICALL                                                     
   27    11        INIT_FCALL                                                   'var_export'
         12        SEND_VAR                                                     !0
         13        DO_ICALL                                                     
         14      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GVb3I
function name:  {closure:/in/GVb3I:19}
number of ops:  41
compiled vars:  !0 = $a, !1 = $b, !2 = $priorities, !3 = $categoryA, !4 = $versionA, !5 = $nameA, !6 = $categoryB, !7 = $versionB, !8 = $nameB
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   20     3        INIT_FCALL                                                   'explode'
          4        SEND_VAL                                                     '+-+'
          5        SEND_VAR                                                     !0
          6        SEND_VAL                                                     3
          7        DO_ICALL                                             $9      
          8        FETCH_LIST_R                                         $10     $9, 0
          9        ASSIGN                                                       !3, $10
         10        FETCH_LIST_R                                         $12     $9, 1
         11        ASSIGN                                                       !4, $12
         12        FETCH_LIST_R                                         $14     $9, 2
         13        ASSIGN                                                       !5, $14
         14        FREE                                                         $9
   21    15        INIT_FCALL                                                   'explode'
         16        SEND_VAL                                                     '+-+'
         17        SEND_VAR                                                     !1
         18        SEND_VAL                                                     3
         19        DO_ICALL                                             $16     
         20        FETCH_LIST_R                                         $17     $16, 0
         21        ASSIGN                                                       !6, $17
         22        FETCH_LIST_R                                         $19     $16, 1
         23        ASSIGN                                                       !7, $19
         24        FETCH_LIST_R                                         $21     $16, 2
         25        ASSIGN                                                       !8, $21
         26        FREE                                                         $16
   23    27        FETCH_DIM_R                                          ~23     !2, !3
         28        FETCH_DIM_R                                          ~24     !2, !6
         29        SPACESHIP                                            ~25     ~23, ~24
         30        JMP_SET                                              ~26     ~25, ->36
   24    31        INIT_FCALL                                                   'version_compare'
         32        SEND_VAR                                                     !7
         33        SEND_VAR                                                     !4
         34        DO_ICALL                                             $27     
         35        QM_ASSIGN                                            ~26     $27
         36        JMP_SET                                              ~28     ~26, ->39
   25    37        SPACESHIP                                            ~29     !5, !8
         38        QM_ASSIGN                                            ~28     ~29
         39      > RETURN                                                       ~28
   26    40*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.18 ms | 2276 KiB | 18 Q