3v4l.org

run code in 300+ PHP versions simultaneously
<?php $langs = [ 5 => "english", 10 => "french", 12 => "german" ]; $posts = [ [ "date" => "13-07-2022", "lang_id" => 5, "amount" => 90, ], [ "date" => "13-07-2022", "lang_id" => 10, "amount" => 34, ], [ "date" => "14-07-2022", "lang_id" => 5, "amount" => 7, ], ]; $defaults = array_fill_keys($langs, 0); $result = []; foreach ($posts as $row) { extract($row); if (!isset($ref[$date])) { $ref[$date] = ['date' => $date] + $defaults; $result[] = &$ref[$date]; } $ref[$date][$langs[$lang_id]] += $amount; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 29
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 29
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 24
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/dBl1b
function name:  (null)
number of ops:  34
compiled vars:  !0 = $langs, !1 = $posts, !2 = $defaults, !3 = $result, !4 = $row, !5 = $ref, !6 = $date, !7 = $lang_id, !8 = $amount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   27     2        INIT_FCALL                                               'array_fill_keys'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        DO_ICALL                                         $11     
          6        ASSIGN                                                   !2, $11
   28     7        ASSIGN                                                   !3, <array>
   29     8      > FE_RESET_R                                       $14     !1, ->29
          9    > > FE_FETCH_R                                               $14, !4, ->29
   30    10    >   INIT_FCALL                                               'extract'
         11        SEND_REF                                                 !4
         12        DO_ICALL                                                 
   31    13        ISSET_ISEMPTY_DIM_OBJ                         0  ~16     !5, !6
         14        BOOL_NOT                                         ~17     ~16
         15      > JMPZ                                                     ~17, ->24
   32    16    >   INIT_ARRAY                                       ~19     !6, 'date'
         17        ADD                                              ~20     ~19, !2
         18        ASSIGN_DIM                                               !5, !6
         19        OP_DATA                                                  ~20
   33    20        FETCH_DIM_W                                      $22     !5, !6
         21        MAKE_REF                                         $23     $22
         22        FETCH_DIM_W                                      $21     !3
         23        ASSIGN_REF                                               $21, $23
   35    24    >   FETCH_DIM_R                                      ~26     !0, !7
         25        FETCH_DIM_RW                                     $25     !5, !6
         26        ASSIGN_DIM_OP                +=               1          $25, ~26
         27        OP_DATA                                                  !8
   29    28      > JMP                                                      ->9
         29    >   FE_FREE                                                  $14
   37    30        INIT_FCALL                                               'var_export'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.2 ms | 1013 KiB | 16 Q