3v4l.org

run code in 500+ PHP versions simultaneously
<?php $labels = [ 0 => "2023-07-05", 1 => "2023-07-06", 2 => "2023-07-07", 3 => "2023-07-08", 4 => "2023-07-09", 5 => "2023-07-10", 6 => "2023-07-11", ]; $result = [ 0 => [ "numberViews" => 20, "dayDate" => "2023-07-10", ], 1 => [ "numberViews" => 32, "dayDate" => "2023-07-11", ], ]; // Create the output array; set the dates/labels as keys and 0 as values $output = array_fill_keys($labels, 0); // Fill the number of views for the dated that have views foreach ($result as $day) { $output[$day['dayDate']] = $day['numberViews']; } print_r($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/Ajspl
function name:  (null)
number of ops:  19
compiled vars:  !0 = $labels, !1 = $result, !2 = $output, !3 = $day
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   13     1        ASSIGN                                                       !1, <array>
   25     2        INIT_FCALL                                                   'array_fill_keys'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     0
          5        DO_ICALL                                             $6      
          6        ASSIGN                                                       !2, $6
   27     7      > FE_RESET_R                                           $8      !1, ->14
          8    > > FE_FETCH_R                                                   $8, !3, ->14
   28     9    >   FETCH_DIM_R                                          ~9      !3, 'dayDate'
         10        FETCH_DIM_R                                          ~11     !3, 'numberViews'
         11        ASSIGN_DIM                                                   !2, ~9
         12        OP_DATA                                                      ~11
   27    13      > JMP                                                          ->8
         14    >   FE_FREE                                                      $8
   31    15        INIT_FCALL                                                   'print_r'
         16        SEND_VAR                                                     !2
         17        DO_ICALL                                                     
         18      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.88 ms | 1793 KiB | 15 Q