3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['a' => 0, 'b' => 2, 'c' => 1, 'd' => 2, 'e' => 3]; $keys = array_keys($array); foreach ($keys as $i => $key) { if ($array[$key] > ($array[$keys[$i - 1]] ?? $array[$keys[$i + 1]] ?? $array[$key] - 1) && $array[$key] > ($array[$keys[$i - 1]] ?? $array[$keys[$i - 1]] ?? $array[$key] - 1) ) { $result[$key] = $array[$key]; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 43
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 43
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 38
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 42
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 42
Branch analysis from position: 38
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/nb8Hv
function name:  (null)
number of ops:  48
compiled vars:  !0 = $array, !1 = $keys, !2 = $key, !3 = $i, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'array_keys'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !1, $6
    6     5      > FE_RESET_R                                       $8      !1, ->43
          6    > > FE_FETCH_R                                       ~9      $8, !2, ->43
          7    >   ASSIGN                                                   !3, ~9
    7     8        FETCH_DIM_R                                      ~11     !0, !2
          9        SUB                                              ~12     !3, 1
         10        FETCH_DIM_R                                      ~13     !1, ~12
         11        FETCH_DIM_IS                                     ~14     !0, ~13
         12        COALESCE                                         ~15     ~14
         13        ADD                                              ~16     !3, 1
         14        FETCH_DIM_R                                      ~17     !1, ~16
         15        FETCH_DIM_IS                                     ~18     !0, ~17
         16        COALESCE                                         ~19     ~18
         17        FETCH_DIM_R                                      ~20     !0, !2
         18        SUB                                              ~21     ~20, 1
         19        QM_ASSIGN                                        ~19     ~21
         20        QM_ASSIGN                                        ~15     ~19
         21        IS_SMALLER                                       ~22     ~15, ~11
         22      > JMPZ_EX                                          ~22     ~22, ->38
    8    23    >   FETCH_DIM_R                                      ~23     !0, !2
         24        SUB                                              ~24     !3, 1
         25        FETCH_DIM_R                                      ~25     !1, ~24
         26        FETCH_DIM_IS                                     ~26     !0, ~25
         27        COALESCE                                         ~27     ~26
         28        SUB                                              ~28     !3, 1
         29        FETCH_DIM_R                                      ~29     !1, ~28
         30        FETCH_DIM_IS                                     ~30     !0, ~29
         31        COALESCE                                         ~31     ~30
         32        FETCH_DIM_R                                      ~32     !0, !2
         33        SUB                                              ~33     ~32, 1
         34        QM_ASSIGN                                        ~31     ~33
         35        QM_ASSIGN                                        ~27     ~31
         36        IS_SMALLER                                       ~34     ~27, ~23
         37        BOOL                                             ~22     ~34
         38    > > JMPZ                                                     ~22, ->42
   10    39    >   FETCH_DIM_R                                      ~36     !0, !2
         40        ASSIGN_DIM                                               !4, !2
         41        OP_DATA                                                  ~36
    6    42    > > JMP                                                      ->6
         43    >   FE_FREE                                                  $8
   13    44        INIT_FCALL                                               'var_export'
         45        SEND_VAR                                                 !4
         46        DO_ICALL                                                 
         47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.65 ms | 1011 KiB | 15 Q