3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tickets = array( array( 'id' => 13, 'pid' => 1, 'owner' => 'jachim', 'time' => '2009-09-25 10:39:42.011612', 'project' => 'jachim.be', 'title' => 'Some random ticket' ), array( 'id' => 31, 'pid' => 2, 'owner' => 'jachim', 'time' => '2009-09-24 14:38:47.945020', 'project' => 'joggink.be', 'title' => 'Some other random ticket' ), array( 'id' => 22, 'pid' => 3, 'owner' => 'root', 'time' => '2009-09-24 10:58:02.904198', 'project' => 'joggink.be', 'title' => 'A specific ticket' ), array( 'id' => 18, 'pid' => 4, 'owner' => 'root', 'time' => '2009-09-24 10:58:02.904198', 'project' => 'joggink.be', 'title' => 'A specific ticket' ) ); function msort($array, $key, $sort_flags = SORT_REGULAR) { if (is_array($array) && count($array) > 0) { if (!empty($key)) { $mapping = array(); foreach ($array as $k => $v) { $sort_key = ''; if (!is_array($key)) { $sort_key = $v[$key]; } else { // @TODO This should be fixed, now it will be sorted as string foreach ($key as $key_key) { $sort_key .= $v[$key_key]; } $sort_flags = SORT_STRING; } $mapping[$k] = $sort_key; } asort($mapping, $sort_flags); $sorted = array(); foreach ($mapping as $k => $v) { $sorted[] = $array[$k]; } return $sorted; } } return $array; } //var_dump($tickets); $tickets = msort($tickets, array('pid','id')); var_dump($tickets); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3LCBj
function name:  (null)
number of ops:  10
compiled vars:  !0 = $tickets
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   68     1        INIT_FCALL                                               'msort'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   70     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   71     9      > RETURN                                                   1

Function msort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 48
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 48
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 33
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 33
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 28
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 46
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 46
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 33
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 8
filename:       /in/3LCBj
function name:  msort
number of ops:  50
compiled vars:  !0 = $array, !1 = $key, !2 = $sort_flags, !3 = $mapping, !4 = $v, !5 = $k, !6 = $sort_key, !7 = $key_key, !8 = $sorted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <const ast>
   39     3        TYPE_CHECK                                  128  ~9      !0
          4      > JMPZ_EX                                          ~9      ~9, ->8
          5    >   COUNT                                            ~10     !0
          6        IS_SMALLER                                       ~11     0, ~10
          7        BOOL                                             ~9      ~11
          8    > > JMPZ                                                     ~9, ->48
   40     9    >   ISSET_ISEMPTY_CV                                 ~12     !1
         10        BOOL_NOT                                         ~13     ~12
         11      > JMPZ                                                     ~13, ->48
   41    12    >   ASSIGN                                                   !3, <array>
   42    13      > FE_RESET_R                                       $15     !0, ->33
         14    > > FE_FETCH_R                                       ~16     $15, !4, ->33
         15    >   ASSIGN                                                   !5, ~16
   43    16        ASSIGN                                                   !6, ''
   44    17        TYPE_CHECK                                  128  ~19     !1
         18        BOOL_NOT                                         ~20     ~19
         19      > JMPZ                                                     ~20, ->23
   45    20    >   FETCH_DIM_R                                      ~21     !4, !1
         21        ASSIGN                                                   !6, ~21
         22      > JMP                                                      ->30
   48    23    > > FE_RESET_R                                       $23     !1, ->28
         24    > > FE_FETCH_R                                               $23, !7, ->28
   49    25    >   FETCH_DIM_R                                      ~24     !4, !7
         26        ASSIGN_OP                                     8          !6, ~24
   48    27      > JMP                                                      ->24
         28    >   FE_FREE                                                  $23
   51    29        ASSIGN                                                   !2, 2
   53    30    >   ASSIGN_DIM                                               !3, !5
         31        OP_DATA                                                  !6
   42    32      > JMP                                                      ->14
         33    >   FE_FREE                                                  $15
   55    34        INIT_FCALL                                               'asort'
         35        SEND_REF                                                 !3
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                                 
   56    38        ASSIGN                                                   !8, <array>
   57    39      > FE_RESET_R                                       $30     !3, ->46
         40    > > FE_FETCH_R                                       ~31     $30, !4, ->46
         41    >   ASSIGN                                                   !5, ~31
   58    42        FETCH_DIM_R                                      ~34     !0, !5
         43        ASSIGN_DIM                                               !8
         44        OP_DATA                                                  ~34
   57    45      > JMP                                                      ->40
         46    >   FE_FREE                                                  $30
   60    47      > RETURN                                                   !8
   63    48    > > RETURN                                                   !0
   64    49*     > RETURN                                                   null

End of function msort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.16 ms | 1394 KiB | 18 Q