3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ "2022-10-30" => ['▶'], "2022-10-31" => ['▶'], "2022-11-07" => ['▶'], "2022-11-09" => ['▶'] ]; $result = []; foreach ($array as $key => $value) { $ym = substr($key, 0, 7); if (!isset($lookup[$ym]) || $lookup[$ym] < $key) { $result[$key] = $value; if (isset($lookup[$ym])) { unset($result[$lookup[$ym]]); } $lookup[$ym] = $key; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
Branch analysis from position: 23
Branch analysis from position: 14
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/WcTd7
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array, !1 = $result, !2 = $value, !3 = $key, !4 = $ym, !5 = $lookup
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1        ASSIGN                                                       !1, <array>
   11     2      > FE_RESET_R                                           $8      !0, ->24
          3    > > FE_FETCH_R                                           ~9      $8, !2, ->24
          4    >   ASSIGN                                                       !3, ~9
   12     5        FRAMELESS_ICALL_3                substr              ~11     !3, 0
          6        OP_DATA                                                      7
          7        ASSIGN                                                       !4, ~11
   13     8        ISSET_ISEMPTY_DIM_OBJ                             0  ~13     !5, !4
          9        BOOL_NOT                                             ~14     ~13
         10      > JMPNZ_EX                                             ~14     ~14, ->14
         11    >   FETCH_DIM_R                                          ~15     !5, !4
         12        IS_SMALLER                                           ~16     ~15, !3
         13        BOOL                                                 ~14     ~16
         14    > > JMPZ                                                         ~14, ->23
   14    15    >   ASSIGN_DIM                                                   !1, !3
         16        OP_DATA                                                      !2
   15    17        ISSET_ISEMPTY_DIM_OBJ                             0          !5, !4
         18      > JMPZ                                                         ~18, ->21
   16    19    >   FETCH_DIM_R                                          ~19     !5, !4
         20        UNSET_DIM                                                    !1, ~19
   18    21    >   ASSIGN_DIM                                                   !5, !4
         22        OP_DATA                                                      !3
   11    23    > > JMP                                                          ->3
         24    >   FE_FREE                                                      $8
   21    25        INIT_FCALL                                                   'var_export'
         26        SEND_VAR                                                     !1
         27        DO_ICALL                                                     
         28      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.27 ms | 1875 KiB | 14 Q