3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array("type"=>"fruit", "price"=>3.50), array("type"=>"milk", "price"=>2.90), array("type"=>"pork", "price"=>5.43), ); $inventory = $data; $time = microtime(true); array_multisort(array_column($inventory, 'price'), SORT_DESC, $inventory); echo microtime(true)-$time; echo "\n\n"; $new = []; $time = microtime(true); foreach($data as $row){ $new[$row['type']] = $row; } ksort($new); echo microtime(true)-$time; echo "\n\n"; print_r($inventory); print_r($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/a2deE
function name:  (null)
number of ops:  49
compiled vars:  !0 = $data, !1 = $inventory, !2 = $time, !3 = $new, !4 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, !0
   11     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !2, $7
   12     6        INIT_FCALL                                               'array_multisort'
          7        INIT_FCALL                                               'array_column'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 'price'
         10        DO_ICALL                                         $9      
         11        SEND_VAL                                                 $9
         12        SEND_VAL                                                 3
         13        SEND_REF                                                 !1
         14        DO_ICALL                                                 
   13    15        INIT_FCALL                                               'microtime'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $11     
         18        SUB                                              ~12     $11, !2
         19        ECHO                                                     ~12
   15    20        ECHO                                                     '%0A%0A'
   17    21        ASSIGN                                                   !3, <array>
   18    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $14     
         25        ASSIGN                                                   !2, $14
   19    26      > FE_RESET_R                                       $16     !0, ->32
         27    > > FE_FETCH_R                                               $16, !4, ->32
   20    28    >   FETCH_DIM_R                                      ~17     !4, 'type'
         29        ASSIGN_DIM                                               !3, ~17
         30        OP_DATA                                                  !4
   19    31      > JMP                                                      ->27
         32    >   FE_FREE                                                  $16
   22    33        INIT_FCALL                                               'ksort'
         34        SEND_REF                                                 !3
         35        DO_ICALL                                                 
   23    36        INIT_FCALL                                               'microtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $20     
         39        SUB                                              ~21     $20, !2
         40        ECHO                                                     ~21
   25    41        ECHO                                                     '%0A%0A'
   27    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !1
         44        DO_ICALL                                                 
   28    45        INIT_FCALL                                               'print_r'
         46        SEND_VAR                                                 !3
         47        DO_ICALL                                                 
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.75 ms | 1400 KiB | 23 Q