3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = microtime(true); for($i = 0; $i < 1000; $i++) { $alreadyOutput = array(); foreach ($results as $result) { if(in_array($result->date, $alreadyOutput)){ continue; } $alreadyOutput[] = $result->date; echo $result->date . "<br />"; } } echo "in_array: ".(microtime(true) - $start)."ms || "; $start2 = microtime(true); for($i = 0; $i < 1000; $i++) { $echoedArray = array(); foreach ($results as $result) { if ($echoedArray[$result->date]) { continue; } echo $result->date . "<br />"; $echoedArray[$result->date] = true; } } echo "by key: ".(microtime(true) - $start2)."ms";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 6
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 40
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 54
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 54
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 40
Branch analysis from position: 58
Branch analysis from position: 40
Branch analysis from position: 54
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 23
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 6
Branch analysis from position: 27
Branch analysis from position: 6
Branch analysis from position: 23
filename:       /in/beMDX
function name:  (null)
number of ops:  66
compiled vars:  !0 = $start, !1 = $i, !2 = $alreadyOutput, !3 = $results, !4 = $result, !5 = $start2, !6 = $echoedArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $7      
          3        ASSIGN                                                   !0, $7
    3     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->25
    4     6    >   ASSIGN                                                   !2, <array>
    5     7      > FE_RESET_R                                       $11     !3, ->23
          8    > > FE_FETCH_R                                               $11, !4, ->23
    6     9    >   INIT_FCALL                                               'in_array'
         10        FETCH_OBJ_R                                      ~12     !4, 'date'
         11        SEND_VAL                                                 ~12
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $13     
         14      > JMPZ                                                     $13, ->16
    7    15    > > JMP                                                      ->8
    9    16    >   FETCH_OBJ_R                                      ~15     !4, 'date'
         17        ASSIGN_DIM                                               !2
         18        OP_DATA                                                  ~15
   10    19        FETCH_OBJ_R                                      ~16     !4, 'date'
         20        CONCAT                                           ~17     ~16, '%3Cbr+%2F%3E'
         21        ECHO                                                     ~17
    5    22      > JMP                                                      ->8
         23    >   FE_FREE                                                  $11
    3    24        PRE_INC                                                  !1
         25    >   IS_SMALLER                                               !1, 1000
         26      > JMPNZ                                                    ~19, ->6
   13    27    >   INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $20     
         30        SUB                                              ~21     $20, !0
         31        CONCAT                                           ~22     'in_array%3A+', ~21
         32        CONCAT                                           ~23     ~22, 'ms+%7C%7C+'
         33        ECHO                                                     ~23
   15    34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $24     
         37        ASSIGN                                                   !5, $24
   16    38        ASSIGN                                                   !1, 0
         39      > JMP                                                      ->56
   17    40    >   ASSIGN                                                   !6, <array>
   18    41      > FE_RESET_R                                       $28     !3, ->54
         42    > > FE_FETCH_R                                               $28, !4, ->54
   19    43    >   FETCH_OBJ_R                                      ~29     !4, 'date'
         44        FETCH_DIM_R                                      ~30     !6, ~29
         45      > JMPZ                                                     ~30, ->47
   20    46    > > JMP                                                      ->42
   22    47    >   FETCH_OBJ_R                                      ~31     !4, 'date'
         48        CONCAT                                           ~32     ~31, '%3Cbr+%2F%3E'
         49        ECHO                                                     ~32
   23    50        FETCH_OBJ_R                                      ~33     !4, 'date'
         51        ASSIGN_DIM                                               !6, ~33
         52        OP_DATA                                                  <true>
   18    53      > JMP                                                      ->42
         54    >   FE_FREE                                                  $28
   16    55        PRE_INC                                                  !1
         56    >   IS_SMALLER                                               !1, 1000
         57      > JMPNZ                                                    ~36, ->40
   26    58    >   INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $37     
         61        SUB                                              ~38     $37, !5
         62        CONCAT                                           ~39     'by+key%3A+', ~38
         63        CONCAT                                           ~40     ~39, 'ms'
         64        ECHO                                                     ~40
         65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.4 ms | 1400 KiB | 17 Q