3v4l.org

run code in 500+ PHP versions simultaneously
<?php $db = [ ['dates' => 'Sep-2022', 'income' => 1864], ['dates' => 'Oct-2022', 'income' => 548] ]; $lookup = array_column($db, null, 'dates'); $year = date('Y'); for ($i = 1; $i < 13 ; ++$i) { $date = date('M-Y', strtotime("$year-$i-01")); $months[] = $lookup[$date] ?? ['dates' => $date, 'income' => 0]; } var_export($months);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 13
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 13
Branch analysis from position: 35
Branch analysis from position: 13
filename:       /in/Gc7qT
function name:  (null)
number of ops:  39
compiled vars:  !0 = $db, !1 = $lookup, !2 = $year, !3 = $i, !4 = $date, !5 = $months
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    7     1        INIT_FCALL                                                   'array_column'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     null
          4        SEND_VAL                                                     'dates'
          5        DO_ICALL                                             $7      
          6        ASSIGN                                                       !1, $7
    9     7        INIT_FCALL                                                   'date'
          8        SEND_VAL                                                     'Y'
          9        DO_ICALL                                             $9      
         10        ASSIGN                                                       !2, $9
   10    11        ASSIGN                                                       !3, 1
         12      > JMP                                                          ->33
   11    13    >   INIT_FCALL                                                   'date'
         14        SEND_VAL                                                     'M-Y'
         15        INIT_FCALL                                                   'strtotime'
         16        ROPE_INIT                                         4  ~13     !2
         17        ROPE_ADD                                          1  ~13     ~13, '-'
         18        ROPE_ADD                                          2  ~13     ~13, !3
         19        ROPE_END                                          3  ~12     ~13, '-01'
         20        SEND_VAL                                                     ~12
         21        DO_ICALL                                             $15     
         22        SEND_VAR                                                     $15
         23        DO_ICALL                                             $16     
         24        ASSIGN                                                       !4, $16
   12    25        FETCH_DIM_IS                                         ~19     !1, !4
         26        COALESCE                                             ~20     ~19
   13    27        INIT_ARRAY                                           ~21     !4, 'dates'
         28        ADD_ARRAY_ELEMENT                                    ~21     0, 'income'
         29        QM_ASSIGN                                            ~20     ~21
   12    30        ASSIGN_DIM                                                   !5
   13    31        OP_DATA                                                      ~20
   10    32        PRE_INC                                                      !3
         33    >   IS_SMALLER                                                   !3, 13
         34      > JMPNZ                                                        ~23, ->13
   15    35    >   INIT_FCALL                                                   'var_export'
         36        SEND_VAR                                                     !5
         37        DO_ICALL                                                     
         38      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159 ms | 2044 KiB | 17 Q