3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( array ('Q1',2017), array ('Q3',2017), array ('Q3',2012), array ('Q4',2015), array ('Q4',2017), array ('Q2',2017), ); $new = array(); foreach($arr as $subarr){ $new[$subarr[1]][] = $subarr[0]; sort($new[$subarr[1]]); } ksort($new); $finalarr = array(); foreach($new as $key => $val){ foreach($val as $k=>$v){ $finalarr[] = array($v, $key); } } echo "<pre>"; print_r($finalarr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 33
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 33
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 31
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 15
filename:       /in/lgPgO
function name:  (null)
number of ops:  39
compiled vars:  !0 = $arr, !1 = $new, !2 = $subarr, !3 = $finalarr, !4 = $val, !5 = $key, !6 = $v, !7 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   13     2      > FE_RESET_R                                       $10     !0, ->15
          3    > > FE_FETCH_R                                               $10, !2, ->15
   14     4    >   FETCH_DIM_R                                      ~11     !2, 1
          5        FETCH_DIM_R                                      ~14     !2, 0
          6        FETCH_DIM_W                                      $12     !1, ~11
          7        ASSIGN_DIM                                               $12
          8        OP_DATA                                                  ~14
   15     9        INIT_FCALL                                               'sort'
         10        FETCH_DIM_R                                      ~15     !2, 1
         11        FETCH_DIM_W                                      $16     !1, ~15
         12        SEND_REF                                                 $16
         13        DO_ICALL                                                 
   13    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $10
   17    16        INIT_FCALL                                               'ksort'
         17        SEND_REF                                                 !1
         18        DO_ICALL                                                 
   18    19        ASSIGN                                                   !3, <array>
   19    20      > FE_RESET_R                                       $20     !1, ->33
         21    > > FE_FETCH_R                                       ~21     $20, !4, ->33
         22    >   ASSIGN                                                   !5, ~21
   20    23      > FE_RESET_R                                       $23     !4, ->31
         24    > > FE_FETCH_R                                       ~24     $23, !6, ->31
         25    >   ASSIGN                                                   !7, ~24
   21    26        INIT_ARRAY                                       ~27     !6
         27        ADD_ARRAY_ELEMENT                                ~27     !5
         28        ASSIGN_DIM                                               !3
         29        OP_DATA                                                  ~27
   20    30      > JMP                                                      ->24
         31    >   FE_FREE                                                  $23
   19    32      > JMP                                                      ->21
         33    >   FE_FREE                                                  $20
   25    34        ECHO                                                     '%3Cpre%3E'
         35        INIT_FCALL                                               'print_r'
         36        SEND_VAR                                                 !3
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.48 ms | 1411 KiB | 19 Q