3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 'strMachineGroupID' => 'MC000027', 'strMachineGroup' => 1, 'April-201904_QTY' => 1, 'February-201902_QTY' => 1, 'January-201901_QTY' => 1, 'July-201907_QTY' => 1, 'June-201906_QTY' => 1, 'March-201903_QTY' => 1, 'May-201905_QTY' => 1, 'strMachineGroupIDUE' => 'MC000027', 'April-201904_UE' => 1.00, 'February-201902_UE' => 1.00, 'January-201901_UE' => 1.00, 'July-201907_UE' => 1.00, 'June-201906_UE' => 1.00, 'March-201903_UE' => 1.00, 'May-201905_UE' => 1.00 ); uksort($array, function ($k1, $k2) { if (preg_match('/^\w+-(\d{6})_\w+$/', $k1, $m1)) { if (preg_match('/^\w+-(\d{6})_\w+$/', $k2, $m2)) { // both have dates, sort on that return strcmp($m1[1], $m2[1]); } else { // dates sort first return -1; } } elseif (preg_match('/^\w+-(\d{6})_\w+$/', $k2, $m2)) { // dates sort first return 1; } else { // neither is a date, sort alphabetically return strcmp($k1, $k2); } }); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZA70u
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'uksort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   40     4        SEND_VAL                                                 ~2
   21     5        DO_ICALL                                                 
   41     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZA70u
function name:  {closure}
number of ops:  38
compiled vars:  !0 = $k1, !1 = $k2, !2 = $m1, !3 = $m2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAL                                                 '%2F%5E%5Cw%2B-%28%5Cd%7B6%7D%29_%5Cw%2B%24%2F'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $4      
          7      > JMPZ                                                     $4, ->24
   23     8    >   INIT_FCALL                                               'preg_match'
          9        SEND_VAL                                                 '%2F%5E%5Cw%2B-%28%5Cd%7B6%7D%29_%5Cw%2B%24%2F'
         10        SEND_VAR                                                 !1
         11        SEND_REF                                                 !3
         12        DO_ICALL                                         $5      
         13      > JMPZ                                                     $5, ->22
   25    14    >   INIT_FCALL                                               'strcmp'
         15        FETCH_DIM_R                                      ~6      !2, 1
         16        SEND_VAL                                                 ~6
         17        FETCH_DIM_R                                      ~7      !3, 1
         18        SEND_VAL                                                 ~7
         19        DO_ICALL                                         $8      
         20      > RETURN                                                   $8
   23    21*       JMP                                                      ->23
   29    22    > > RETURN                                                   -1
   22    23*       JMP                                                      ->37
   32    24    >   INIT_FCALL                                               'preg_match'
         25        SEND_VAL                                                 '%2F%5E%5Cw%2B-%28%5Cd%7B6%7D%29_%5Cw%2B%24%2F'
         26        SEND_VAR                                                 !1
         27        SEND_REF                                                 !3
         28        DO_ICALL                                         $9      
         29      > JMPZ                                                     $9, ->32
   34    30    > > RETURN                                                   1
   32    31*       JMP                                                      ->37
   38    32    >   INIT_FCALL                                               'strcmp'
         33        SEND_VAR                                                 !0
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                         $10     
         36      > RETURN                                                   $10
   40    37*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.04 ms | 1022 KiB | 17 Q