3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = array( 0 => array('id' => 8, 'month' => 1, 'cost' => 12500), 1 => array('id' => 8, 'month' => 2, 'cost' => 14200), 2 => array('id' => 9, 'month' => 1, 'cost' => 23000), 3 => array('id' => 9, 'month' => 2, 'cost' => 18000), ); $by_id = []; foreach($data as $x) { $by_id[$x['id']][$x['month']] = $x['cost']; // e.g. $by_id[8][2] = 14200; } $html = []; $html[] = '<table>'; $html[] = '<tr><th>ID</th><th>Jan</th><th>Feb</th></tr>'; foreach($by_id as $id => $months) { $html[] = '<tr>'; $html[] = "<td>{$id}</td>"; foreach($months as $month => $cost) { $html[] = "<td>{$cost}</td>"; } $html[] = '</tr>'; } $html[] = '</table>'; echo implode("\n", $html);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 40
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 40
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 36
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 36
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 36
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 11
filename:       /in/7CFRf
function name:  (null)
number of ops:  46
compiled vars:  !0 = $data, !1 = $by_id, !2 = $x, !3 = $html, !4 = $months, !5 = $id, !6 = $cost, !7 = $month
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1        ASSIGN                                                       !1, <array>
   12     2      > FE_RESET_R                                           $10     !0, ->11
          3    > > FE_FETCH_R                                                   $10, !2, ->11
   13     4    >   FETCH_DIM_R                                          ~11     !2, 'id'
          5        FETCH_DIM_R                                          ~13     !2, 'month'
          6        FETCH_DIM_R                                          ~15     !2, 'cost'
          7        FETCH_DIM_W                                          $12     !1, ~11
          8        ASSIGN_DIM                                                   $12, ~13
          9        OP_DATA                                                      ~15
   12    10      > JMP                                                          ->3
         11    >   FE_FREE                                                      $10
   18    12        ASSIGN                                                       !3, <array>
   19    13        ASSIGN_DIM                                                   !3
         14        OP_DATA                                                      '%3Ctable%3E'
   20    15        ASSIGN_DIM                                                   !3
         16        OP_DATA                                                      '%3Ctr%3E%3Cth%3EID%3C%2Fth%3E%3Cth%3EJan%3C%2Fth%3E%3Cth%3EFeb%3C%2Fth%3E%3C%2Ftr%3E'
   22    17      > FE_RESET_R                                           $19     !1, ->40
         18    > > FE_FETCH_R                                           ~20     $19, !4, ->40
         19    >   ASSIGN                                                       !5, ~20
   23    20        ASSIGN_DIM                                                   !3
         21        OP_DATA                                                      '%3Ctr%3E'
   24    22        ROPE_INIT                                         3  ~25     '%3Ctd%3E'
         23        ROPE_ADD                                          1  ~25     ~25, !5
         24        ROPE_END                                          2  ~24     ~25, '%3C%2Ftd%3E'
         25        ASSIGN_DIM                                                   !3
         26        OP_DATA                                                      ~24
   25    27      > FE_RESET_R                                           $27     !4, ->36
         28    > > FE_FETCH_R                                           ~28     $27, !6, ->36
         29    >   ASSIGN                                                       !7, ~28
   26    30        ROPE_INIT                                         3  ~32     '%3Ctd%3E'
         31        ROPE_ADD                                          1  ~32     ~32, !6
         32        ROPE_END                                          2  ~31     ~32, '%3C%2Ftd%3E'
         33        ASSIGN_DIM                                                   !3
         34        OP_DATA                                                      ~31
   25    35      > JMP                                                          ->28
         36    >   FE_FREE                                                      $27
   29    37        ASSIGN_DIM                                                   !3
         38        OP_DATA                                                      '%3C%2Ftr%3E'
   22    39      > JMP                                                          ->18
         40    >   FE_FREE                                                      $19
   32    41        ASSIGN_DIM                                                   !3
         42        OP_DATA                                                      '%3C%2Ftable%3E'
   34    43        FRAMELESS_ICALL_2                implode             ~36     '%0A', !3
         44        ECHO                                                         ~36
         45      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
206.73 ms | 1905 KiB | 13 Q