3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_alternate_multisort($array, ...$args) { foreach ($args as $i => $arg) { $sortParams[] = $i & 1 ? $arg : array_column($array, $arg); } $sortParams[] = &$array; array_multisort(...$sortParams); return $array; } $alliances = [ ['id' => 1, 'output' => '1', 'score' => 10], ['id' => 2, 'output' => '0', 'score' => 9], ['id' => 3, 'output' => '1', 'score' => 11], ['id' => 4, 'output' => '1', 'score' => 9], ['id' => 5, 'output' => '0', 'score' => 10], ]; $alliances = array_alternate_multisort($alliances, "output", SORT_DESC, "score", SORT_DESC); var_export($alliances);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bJXYe
function name:  (null)
number of ops:  13
compiled vars:  !0 = $alliances
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'array_alternate_multisort'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'output'
          4        SEND_VAL                                                 3
          5        SEND_VAL                                                 'score'
          6        SEND_VAL                                                 3
          7        DO_FCALL                                      0  $2      
          8        ASSIGN                                                   !0, $2
   22     9        INIT_FCALL                                               'var_export'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function array_alternate_multisort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/bJXYe
function name:  array_alternate_multisort
number of ops:  26
compiled vars:  !0 = $array, !1 = $args, !2 = $arg, !3 = $i, !4 = $sortParams
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
    4     2      > FE_RESET_R                                       $5      !1, ->17
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->17
          4    >   ASSIGN                                                   !3, ~6
    5     5        BW_AND                                           ~9      !3, 1
          6      > JMPZ                                                     ~9, ->9
          7    >   QM_ASSIGN                                        ~10     !2
          8      > JMP                                                      ->14
          9    >   INIT_FCALL                                               'array_column'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $11     
         13        QM_ASSIGN                                        ~10     $11
         14    >   ASSIGN_DIM                                               !4
         15        OP_DATA                                                  ~10
    4    16      > JMP                                                      ->3
         17    >   FE_FREE                                                  $5
    7    18        FETCH_DIM_W                                      $12     !4
         19        ASSIGN_REF                                               $12, !0
    8    20        INIT_FCALL                                               'array_multisort'
         21        SEND_UNPACK                                              !4
         22        CHECK_UNDEF_ARGS                                         
         23        DO_ICALL                                                 
    9    24      > RETURN                                                   !0
   10    25*     > RETURN                                                   null

End of function array_alternate_multisort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.21 ms | 1446 KiB | 17 Q