3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = [ 'key1' => 'value1', 'key2' => ['value21','value22'], 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5' ]; $fields = ['key1', 'key2', 'key4']; $row = []; $time_start1 = microtime(true); foreach ($fields as $alias => $field) { if (!is_array($field)) { if (isset($values[$field])) { echo "catch11\n"; $row[$field] = $values[$field]; } else if (isset($mileage[$alias])) { echo "catch12\n"; $row[$field] = $values[$alias]; } } else { if (isset($values[$field])) { echo "catch21\n"; $row[$field] = $values[$field]; } else if (isset($values[$alias])) { echo "catch22\n"; $row[$field] = $values[$alias]; } } } $time_end1 = microtime(true); $time1 = $time_end1 - $time_start1; var_dump($row); echo "Did in $time1 seconds\n"; unset($row); $time_start2 = microtime(true); $row= []; foreach ($fields as $alias => $field) { if (is_array($field)) { if (isset($values[$field])) { echo "catch11\n"; $row[$field] = $values[$field]; } else if (isset($values[$alias])) { $row[$field] = $values[$alias]; } } else { if (isset($values[$field])) { $row[$field] = $values[$field]; } else if (isset($values[$alias])) { $row[$field] = $values[$alias];} } } $time_end2 = microtime(true); $time2 = $time_end2 - $time_start2; var_dump($row); echo "Did in $time2 seconds\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 41
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 41
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 26
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 40
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 40
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 62, Position 2 = 91
Branch analysis from position: 62
2 jumps found. (Code = 78) Position 1 = 63, Position 2 = 91
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 79
Branch analysis from position: 66
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 73
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 78
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
Branch analysis from position: 78
Branch analysis from position: 79
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 85
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
Branch analysis from position: 85
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 90
Branch analysis from position: 87
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
Branch analysis from position: 90
Branch analysis from position: 91
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 91
Branch analysis from position: 41
filename:       /in/pXmpi
function name:  (null)
number of ops:  106
compiled vars:  !0 = $values, !1 = $fields, !2 = $row, !3 = $time_start1, !4 = $field, !5 = $alias, !6 = $mileage, !7 = $time_end1, !8 = $time1, !9 = $time_start2, !10 = $time_end2, !11 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   13     2        ASSIGN                                                   !2, <array>
   15     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $15     
          6        ASSIGN                                                   !3, $15
   17     7      > FE_RESET_R                                       $17     !1, ->41
          8    > > FE_FETCH_R                                       ~18     $17, !4, ->41
          9    >   ASSIGN                                                   !5, ~18
   18    10        TYPE_CHECK                                  128  ~20     !4
         11        BOOL_NOT                                         ~21     ~20
         12      > JMPZ                                                     ~21, ->27
   19    13    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !4
         14      > JMPZ                                                     ~22, ->20
   20    15    >   ECHO                                                     'catch11%0A'
   22    16        FETCH_DIM_R                                      ~24     !0, !4
         17        ASSIGN_DIM                                               !2, !4
         18        OP_DATA                                                  ~24
         19      > JMP                                                      ->26
   23    20    >   ISSET_ISEMPTY_DIM_OBJ                         0          !6, !5
         21      > JMPZ                                                     ~25, ->26
   24    22    >   ECHO                                                     'catch12%0A'
   26    23        FETCH_DIM_R                                      ~27     !0, !5
         24        ASSIGN_DIM                                               !2, !4
         25        OP_DATA                                                  ~27
         26    > > JMP                                                      ->40
   30    27    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !4
         28      > JMPZ                                                     ~28, ->34
   31    29    >   ECHO                                                     'catch21%0A'
   33    30        FETCH_DIM_R                                      ~30     !0, !4
         31        ASSIGN_DIM                                               !2, !4
         32        OP_DATA                                                  ~30
         33      > JMP                                                      ->40
   34    34    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !5
         35      > JMPZ                                                     ~31, ->40
   35    36    >   ECHO                                                     'catch22%0A'
   37    37        FETCH_DIM_R                                      ~33     !0, !5
         38        ASSIGN_DIM                                               !2, !4
         39        OP_DATA                                                  ~33
   17    40    > > JMP                                                      ->8
         41    >   FE_FREE                                                  $17
   41    42        INIT_FCALL                                               'microtime'
         43        SEND_VAL                                                 <true>
         44        DO_ICALL                                         $34     
         45        ASSIGN                                                   !7, $34
   42    46        SUB                                              ~36     !7, !3
         47        ASSIGN                                                   !8, ~36
   43    48        INIT_FCALL                                               'var_dump'
         49        SEND_VAR                                                 !2
         50        DO_ICALL                                                 
   45    51        ROPE_INIT                                     3  ~40     'Did+in+'
         52        ROPE_ADD                                      1  ~40     ~40, !8
         53        ROPE_END                                      2  ~39     ~40, '+seconds%0A'
         54        ECHO                                                     ~39
   48    55        UNSET_CV                                                 !2
   50    56        INIT_FCALL                                               'microtime'
         57        SEND_VAL                                                 <true>
         58        DO_ICALL                                         $42     
         59        ASSIGN                                                   !9, $42
   52    60        ASSIGN                                                   !2, <array>
   54    61      > FE_RESET_R                                       $45     !1, ->91
         62    > > FE_FETCH_R                                       ~46     $45, !4, ->91
         63    >   ASSIGN                                                   !5, ~46
   55    64        TYPE_CHECK                                  128          !4
         65      > JMPZ                                                     ~48, ->79
   57    66    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !4
         67      > JMPZ                                                     ~49, ->73
   58    68    >   ECHO                                                     'catch11%0A'
   59    69        FETCH_DIM_R                                      ~51     !0, !4
         70        ASSIGN_DIM                                               !2, !4
         71        OP_DATA                                                  ~51
         72      > JMP                                                      ->78
   60    73    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !5
         74      > JMPZ                                                     ~52, ->78
   62    75    >   FETCH_DIM_R                                      ~54     !0, !5
         76        ASSIGN_DIM                                               !2, !4
         77        OP_DATA                                                  ~54
         78    > > JMP                                                      ->90
   67    79    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !4
         80      > JMPZ                                                     ~55, ->85
   68    81    >   FETCH_DIM_R                                      ~57     !0, !4
         82        ASSIGN_DIM                                               !2, !4
         83        OP_DATA                                                  ~57
         84      > JMP                                                      ->90
   69    85    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !5
         86      > JMPZ                                                     ~58, ->90
   70    87    >   FETCH_DIM_R                                      ~60     !0, !5
         88        ASSIGN_DIM                                               !2, !4
         89        OP_DATA                                                  ~60
   54    90    > > JMP                                                      ->62
         91    >   FE_FREE                                                  $45
   75    92        INIT_FCALL                                               'microtime'
         93        SEND_VAL                                                 <true>
         94        DO_ICALL                                         $61     
         95        ASSIGN                                                   !10, $61
   76    96        SUB                                              ~63     !10, !9
         97        ASSIGN                                                   !11, ~63
   77    98        INIT_FCALL                                               'var_dump'
         99        SEND_VAR                                                 !2
        100        DO_ICALL                                                 
   78   101        ROPE_INIT                                     3  ~67     'Did+in+'
        102        ROPE_ADD                                      1  ~67     ~67, !11
        103        ROPE_END                                      2  ~66     ~67, '+seconds%0A'
        104        ECHO                                                     ~66
        105      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.97 ms | 1404 KiB | 17 Q