3v4l.org

run code in 300+ PHP versions simultaneously
<?php $log = array ( array('Red', 'Steel'), array('Red', 'Wood'), array('Blue', 'Wood') ); $materials = array(); $colors = array(); foreach($log as $line) { $colors[$line[0]] = (!isset($colors[$line[0]])) ? 1 : $colors[$line[0]] + 1; $materials[$line[1]] = (!isset($materials[$line[1]])) ? 1 : $materials[$line[1]] + 1; } ?> <h2>Colors</h2>\n <?php foreach ($colors as $color => $amount) echo "{$color} => {$amount}<br>\n"; ?> <h2>Materials</h2>\n <?php foreach ($materials as $material => $amount) echo "{$material} => {$amount}<br>\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 32
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
Branch analysis from position: 25
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 43
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 43
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 54
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 54
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 43
Branch analysis from position: 32
filename:       /in/g1V83
function name:  (null)
number of ops:  56
compiled vars:  !0 = $log, !1 = $materials, !2 = $colors, !3 = $line, !4 = $amount, !5 = $color, !6 = $material
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   10     2        ASSIGN                                                   !2, <array>
   12     3      > FE_RESET_R                                       $10     !0, ->32
          4    > > FE_FETCH_R                                               $10, !3, ->32
   13     5    >   FETCH_DIM_R                                      ~11     !3, 0
          6        FETCH_DIM_R                                      ~13     !3, 0
          7        ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !2, ~13
          8        BOOL_NOT                                         ~15     ~14
          9      > JMPZ                                                     ~15, ->12
         10    >   QM_ASSIGN                                        ~16     1
         11      > JMP                                                      ->16
         12    >   FETCH_DIM_R                                      ~17     !3, 0
         13        FETCH_DIM_R                                      ~18     !2, ~17
         14        ADD                                              ~19     ~18, 1
         15        QM_ASSIGN                                        ~16     ~19
         16    >   ASSIGN_DIM                                               !2, ~11
         17        OP_DATA                                                  ~16
   14    18        FETCH_DIM_R                                      ~20     !3, 1
         19        FETCH_DIM_R                                      ~22     !3, 1
         20        ISSET_ISEMPTY_DIM_OBJ                         0  ~23     !1, ~22
         21        BOOL_NOT                                         ~24     ~23
         22      > JMPZ                                                     ~24, ->25
         23    >   QM_ASSIGN                                        ~25     1
         24      > JMP                                                      ->29
         25    >   FETCH_DIM_R                                      ~26     !3, 1
         26        FETCH_DIM_R                                      ~27     !1, ~26
         27        ADD                                              ~28     ~27, 1
         28        QM_ASSIGN                                        ~25     ~28
         29    >   ASSIGN_DIM                                               !1, ~20
         30        OP_DATA                                                  ~25
   12    31      > JMP                                                      ->4
         32    >   FE_FREE                                                  $10
   18    33        ECHO                                                     '%0A%3Ch2%3EColors%3C%2Fh2%3E%5Cn%0A'
   21    34      > FE_RESET_R                                       $29     !2, ->43
         35    > > FE_FETCH_R                                       ~30     $29, !4, ->43
         36    >   ASSIGN                                                   !5, ~30
   22    37        ROPE_INIT                                     4  ~33     !5
         38        ROPE_ADD                                      1  ~33     ~33, '+%3D%3E+'
         39        ROPE_ADD                                      2  ~33     ~33, !4
         40        ROPE_END                                      3  ~32     ~33, '%3Cbr%3E%0A'
         41        ECHO                                                     ~32
   21    42      > JMP                                                      ->35
         43    >   FE_FREE                                                  $29
   24    44        ECHO                                                     '%3Ch2%3EMaterials%3C%2Fh2%3E%5Cn%0A'
   26    45      > FE_RESET_R                                       $35     !1, ->54
         46    > > FE_FETCH_R                                       ~36     $35, !4, ->54
         47    >   ASSIGN                                                   !6, ~36
   27    48        ROPE_INIT                                     4  ~39     !6
         49        ROPE_ADD                                      1  ~39     ~39, '+%3D%3E+'
         50        ROPE_ADD                                      2  ~39     ~39, !4
         51        ROPE_END                                      3  ~38     ~39, '%3Cbr%3E%0A'
         52        ECHO                                                     ~38
   26    53      > JMP                                                      ->46
         54    >   FE_FREE                                                  $35
   28    55      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.75 ms | 1399 KiB | 13 Q