3v4l.org

run code in 300+ PHP versions simultaneously
<?php $people = array( array("name"=>"Bob","age"=>8,"colour"=>"red"), array("name"=>"Greg","age"=>12,"colour"=>"blue"), array("name"=>"Andy","age"=>5,"colour"=>"purple") ); $arrSortArray = array(); foreach($people as $person) { foreach($person as $key=>$value){ if(!isset($arrSortArray[$key])){ $arrSortArray[$key] = array(); } $arrSortArray[$key][] = $person; } } $orderby = "name"; //change this to whatever key you want from the array var_dump($arrSortArray[$orderby]); array_multisort($arrSortArray[$orderby], SORT_ASC,$people); var_dump($arrSortArray[$orderby]);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/uEvu7
function name:  (null)
number of ops:  35
compiled vars:  !0 = $people, !1 = $arrSortArray, !2 = $person, !3 = $value, !4 = $key, !5 = $orderby
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   11     2      > FE_RESET_R                                       $8      !0, ->18
          3    > > FE_FETCH_R                                               $8, !2, ->18
   12     4    > > FE_RESET_R                                       $9      !2, ->16
          5    > > FE_FETCH_R                                       ~10     $9, !3, ->16
          6    >   ASSIGN                                                   !4, ~10
   13     7        ISSET_ISEMPTY_DIM_OBJ                         0  ~12     !1, !4
          8        BOOL_NOT                                         ~13     ~12
          9      > JMPZ                                                     ~13, ->12
   14    10    >   ASSIGN_DIM                                               !1, !4
         11        OP_DATA                                                  <array>
   16    12    >   FETCH_DIM_W                                      $15     !1, !4
         13        ASSIGN_DIM                                               $15
         14        OP_DATA                                                  !2
   12    15      > JMP                                                      ->5
         16    >   FE_FREE                                                  $9
   11    17      > JMP                                                      ->3
         18    >   FE_FREE                                                  $8
   20    19        ASSIGN                                                   !5, 'name'
   22    20        INIT_FCALL                                               'var_dump'
         21        FETCH_DIM_R                                      ~18     !1, !5
         22        SEND_VAL                                                 ~18
         23        DO_ICALL                                                 
   24    24        INIT_FCALL                                               'array_multisort'
         25        FETCH_DIM_W                                      $20     !1, !5
         26        SEND_REF                                                 $20
         27        SEND_VAL                                                 4
         28        SEND_REF                                                 !0
         29        DO_ICALL                                                 
   26    30        INIT_FCALL                                               'var_dump'
         31        FETCH_DIM_R                                      ~22     !1, !5
         32        SEND_VAL                                                 ~22
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.6 ms | 1392 KiB | 17 Q