3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jobs = [ ['count' => 3, 'yearmonth' => '2019-7'], ['count' => 3, 'yearmonth' => '2019-9'], ['count' => 5, 'yearmonth' => '2019-10'], ]; $dates = [ ['yearmonth' => '2019-6'], ['yearmonth' => '2019-7'], ['yearmonth' => '2019-8'], ['yearmonth' => '2019-9'], ['yearmonth' => '2019-10'], ]; $lookup = array_column($jobs, null, 'yearmonth'); $result = []; foreach ($dates as $date) { $result[] = $lookup[$date['yearmonth']] ?? ['count' => 0] + $date; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/cHoIZ
function name:  (null)
number of ops:  24
compiled vars:  !0 = $jobs, !1 = $dates, !2 = $lookup, !3 = $result, !4 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   16     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'yearmonth'
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   18     8        ASSIGN                                                   !3, <array>
   19     9      > FE_RESET_R                                       $10     !1, ->19
         10    > > FE_FETCH_R                                               $10, !4, ->19
   20    11    >   FETCH_DIM_R                                      ~12     !4, 'yearmonth'
         12        FETCH_DIM_IS                                     ~13     !2, ~12
         13        COALESCE                                         ~14     ~13
         14        ADD                                              ~15     <array>, !4
         15        QM_ASSIGN                                        ~14     ~15
         16        ASSIGN_DIM                                               !3
         17        OP_DATA                                                  ~14
   19    18      > JMP                                                      ->10
         19    >   FE_FREE                                                  $10
   23    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.38 ms | 953 KiB | 15 Q