3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a=array('FA',12.9); $b=array('FA',12.9); $c=array('FB',12.2); $d=array('FC',12.3); $e=array('FA',12.9); $h=array('FA',12.4); $f=array('FB',12.9); $items=array($a,$b,$c,$d,$e,$f,$h); // Count in two different but functionally identical ways $counts_a = []; $counts_b = []; foreach($items as $item) { // Suppress the warning for missing key @$counts_a[$item[0] . ' ' . $item[1]]++; // Actually look for the key and set to zero if not found $key = $item[0] . ' ' . $item[1]; if(!array_key_exists($key, $counts_b)){ $counts_b[$key] = 0; } $counts_b[$key]++; } foreach($counts_a as $key => $count) { echo $key . 'x' . $count, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
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 = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 37
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 49
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 49
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 40
filename:       /in/hfQCK
function name:  (null)
number of ops:  51
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d, !4 = $e, !5 = $h, !6 = $f, !7 = $items, !8 = $counts_a, !9 = $counts_b, !10 = $item, !11 = $key, !12 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, <array>
    7     4        ASSIGN                                                   !4, <array>
    8     5        ASSIGN                                                   !5, <array>
    9     6        ASSIGN                                                   !6, <array>
   10     7        INIT_ARRAY                                       ~20     !0
          8        ADD_ARRAY_ELEMENT                                ~20     !1
          9        ADD_ARRAY_ELEMENT                                ~20     !2
         10        ADD_ARRAY_ELEMENT                                ~20     !3
         11        ADD_ARRAY_ELEMENT                                ~20     !4
         12        ADD_ARRAY_ELEMENT                                ~20     !6
         13        ADD_ARRAY_ELEMENT                                ~20     !5
         14        ASSIGN                                                   !7, ~20
   13    15        ASSIGN                                                   !8, <array>
   14    16        ASSIGN                                                   !9, <array>
   15    17      > FE_RESET_R                                       $24     !7, ->40
         18    > > FE_FETCH_R                                               $24, !10, ->40
   17    19    >   BEGIN_SILENCE                                    ~25     
         20        FETCH_DIM_R                                      ~26     !10, 0
         21        CONCAT                                           ~27     ~26, '+'
         22        FETCH_DIM_R                                      ~28     !10, 1
         23        CONCAT                                           ~29     ~27, ~28
         24        FETCH_DIM_RW                                     $30     !8, ~29
         25        PRE_INC                                                  $30
         26        END_SILENCE                                              ~25
   20    27        FETCH_DIM_R                                      ~32     !10, 0
         28        CONCAT                                           ~33     ~32, '+'
         29        FETCH_DIM_R                                      ~34     !10, 1
         30        CONCAT                                           ~35     ~33, ~34
         31        ASSIGN                                                   !11, ~35
   21    32        ARRAY_KEY_EXISTS                                 ~37     !11, !9
         33        BOOL_NOT                                         ~38     ~37
         34      > JMPZ                                                     ~38, ->37
   22    35    >   ASSIGN_DIM                                               !9, !11
         36        OP_DATA                                                  0
   24    37    >   FETCH_DIM_RW                                     $40     !9, !11
         38        PRE_INC                                                  $40
   15    39      > JMP                                                      ->18
         40    >   FE_FREE                                                  $24
   28    41      > FE_RESET_R                                       $42     !8, ->49
         42    > > FE_FETCH_R                                       ~43     $42, !12, ->49
         43    >   ASSIGN                                                   !11, ~43
   29    44        CONCAT                                           ~45     !11, 'x'
         45        CONCAT                                           ~46     ~45, !12
         46        ECHO                                                     ~46
         47        ECHO                                                     '%0A'
   28    48      > JMP                                                      ->42
         49    >   FE_FREE                                                  $42
   30    50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.74 ms | 1004 KiB | 13 Q