3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = array( array( 'position' => 1, 'col1' => 10, 'col2' => 10, ), array( 'position' => 2, 'col1' => 12, 'col2' => 10, ), array( 'position' => 3, 'col1' => 10, 'col2' => 11, ), ); $col1_data = array(); $col2_data = array(); foreach ($result as $key => $row) { $col1_data[] = intval($row['col1']); $col2_data[] = intval($row['col2']); } // SORT_DESC ! array_multisort($result, $col1_data, SORT_DESC, SORT_NUMERIC, $col2_data, SORT_DESC, SORT_NUMERIC); foreach ($result as $row) { echo $row['position'], ' '; } echo "\n"; // Actual: 1 3 2 // Expected: 2 3 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 15
filename:       /in/fv0YA
function name:  (null)
number of ops:  34
compiled vars:  !0 = $result, !1 = $col1_data, !2 = $col2_data, !3 = $row, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   22     2        ASSIGN                                                   !2, <array>
   23     3      > FE_RESET_R                                       $8      !0, ->15
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->15
          5    >   ASSIGN                                                   !4, ~9
   24     6        FETCH_DIM_R                                      ~12     !3, 'col1'
          7        CAST                                          4  ~13     ~12
          8        ASSIGN_DIM                                               !1
          9        OP_DATA                                                  ~13
   25    10        FETCH_DIM_R                                      ~15     !3, 'col2'
         11        CAST                                          4  ~16     ~15
         12        ASSIGN_DIM                                               !2
         13        OP_DATA                                                  ~16
   23    14      > JMP                                                      ->4
         15    >   FE_FREE                                                  $8
   28    16        INIT_FCALL                                               'array_multisort'
         17        SEND_REF                                                 !0
         18        SEND_REF                                                 !1
         19        SEND_VAL                                                 3
         20        SEND_VAL                                                 1
         21        SEND_REF                                                 !2
         22        SEND_VAL                                                 3
         23        SEND_VAL                                                 1
         24        DO_ICALL                                                 
   30    25      > FE_RESET_R                                       $18     !0, ->31
         26    > > FE_FETCH_R                                               $18, !3, ->31
   31    27    >   FETCH_DIM_R                                      ~19     !3, 'position'
         28        ECHO                                                     ~19
         29        ECHO                                                     '+'
   30    30      > JMP                                                      ->26
         31    >   FE_FREE                                                  $18
   33    32        ECHO                                                     '%0A'
   35    33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.99 ms | 1401 KiB | 15 Q