3v4l.org

run code in 300+ PHP versions simultaneously
<?php $example1 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "111111", "ExpDate" => "2013-07-31", "Level" => "WELITE", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); $example2 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "222222", "ExpDate" => "2013-07-31", "Level" => "WELITE", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); $example3 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "22222", "ExpDate" => "2013-07-31", "Level" => "DEMO", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); $example4 = array( "OrgID" => "XXXX", "DOB" => "1970-01-01", "PersonID" => "22222", "ExpDate" => "2013-07-31", "Level" => "DEMO", "Status" => "Active", "FName" => "Jane", "LName" => "Doe", "Checked" => null ); // Initial array $initArray = array($example1, $example2, $example3, $example4); $finalArray = array(); $i = 0; foreach ($initArray as $key => $value) { (isset($value['Level'])) ? $finalArray[$value['Level']][$i] = $value : NULL; unset($finalArray[$value['Level']][$i]['Level']); // Add this line to fix indexes sort($finalArray[$value['Level']]); $i++; } echo '<pre>', print_r($finalArray, true), '</pre>';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 35
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 35
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/32J9n
function name:  (null)
number of ops:  44
compiled vars:  !0 = $example1, !1 = $example2, !2 = $example3, !3 = $example4, !4 = $initArray, !5 = $finalArray, !6 = $i, !7 = $value, !8 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   26     2        ASSIGN                                                   !2, <array>
   38     3        ASSIGN                                                   !3, <array>
   51     4        INIT_ARRAY                                       ~13     !0
          5        ADD_ARRAY_ELEMENT                                ~13     !1
          6        ADD_ARRAY_ELEMENT                                ~13     !2
          7        ADD_ARRAY_ELEMENT                                ~13     !3
          8        ASSIGN                                                   !4, ~13
   53     9        ASSIGN                                                   !5, <array>
   54    10        ASSIGN                                                   !6, 0
   55    11      > FE_RESET_R                                       $17     !4, ->35
         12    > > FE_FETCH_R                                       ~18     $17, !7, ->35
         13    >   ASSIGN                                                   !8, ~18
   56    14        ISSET_ISEMPTY_DIM_OBJ                         0          !7, 'Level'
         15      > JMPZ                                                     ~20, ->22
         16    >   FETCH_DIM_R                                      ~21     !7, 'Level'
         17        FETCH_DIM_W                                      $22     !5, ~21
         18        ASSIGN_DIM                                       ~23     $22, !6
         19        OP_DATA                                                  !7
         20        QM_ASSIGN                                        ~24     ~23
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~24     null
         23    >   FREE                                                     ~24
   57    24        FETCH_DIM_R                                      ~25     !7, 'Level'
         25        FETCH_DIM_UNSET                                  $26     !5, ~25
         26        FETCH_DIM_UNSET                                  $27     $26, !6
         27        UNSET_DIM                                                $27, 'Level'
   59    28        INIT_FCALL                                               'sort'
         29        FETCH_DIM_R                                      ~28     !7, 'Level'
         30        FETCH_DIM_W                                      $29     !5, ~28
         31        SEND_REF                                                 $29
         32        DO_ICALL                                                 
   60    33        PRE_INC                                                  !6
   55    34      > JMP                                                      ->12
         35    >   FE_FREE                                                  $17
   63    36        ECHO                                                     '%3Cpre%3E'
         37        INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !5
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $32     
         41        ECHO                                                     $32
         42        ECHO                                                     '%3C%2Fpre%3E'
         43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.18 ms | 1400 KiB | 17 Q