3v4l.org

run code in 300+ PHP versions simultaneously
<?php $product_details = [ "0" => [ "brand_id" => 1, "product_type" => 1, ], "1" => [ "brand_id" => 2, "product_type" => 1, ], "2" => [ "brand_id" => 1, "product_type" => 1, ], "3" => [ "brand_id" => 2, "product_type" => 1, ], ]; function sortByOrder($a, $b) { return $a['brand_id'] - $b['brand_id']; } usort($product_details, 'sortByOrder'); $result = []; foreach ($product_details as $key => $value) { $result['brand_id'.$value['brand_id']][] = $value; } extract($result); print_r($brand_id1); print_r($brand_id2);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/4UGLY
function name:  (null)
number of ops:  26
compiled vars:  !0 = $product_details, !1 = $result, !2 = $value, !3 = $key, !4 = $brand_id1, !5 = $brand_id2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'sortByOrder'
          4        DO_ICALL                                                 
   37     5        ASSIGN                                                   !1, <array>
   38     6      > FE_RESET_R                                       $9      !0, ->15
          7    > > FE_FETCH_R                                       ~10     $9, !2, ->15
          8    >   ASSIGN                                                   !3, ~10
   39     9        FETCH_DIM_R                                      ~12     !2, 'brand_id'
         10        CONCAT                                           ~13     'brand_id', ~12
         11        FETCH_DIM_W                                      $14     !1, ~13
         12        ASSIGN_DIM                                               $14
         13        OP_DATA                                                  !2
   38    14      > JMP                                                      ->7
         15    >   FE_FREE                                                  $9
   41    16        INIT_FCALL                                               'extract'
         17        SEND_REF                                                 !1
         18        DO_ICALL                                                 
   42    19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !4
         21        DO_ICALL                                                 
   43    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !5
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Function sortbyorder:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4UGLY
function name:  sortByOrder
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   33     2        FETCH_DIM_R                                      ~2      !0, 'brand_id'
          3        FETCH_DIM_R                                      ~3      !1, 'brand_id'
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   34     6*     > RETURN                                                   null

End of function sortbyorder

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.59 ms | 1013 KiB | 16 Q