3v4l.org

run code in 500+ PHP versions simultaneously
<?php $fonts = [ [ 'family' => 'Abril Fatface', 'weight' => 'regular', 'charset' => 'latin,latin-ext' ], [ 'family' => 'Akronim', 'weight' => 'regular', 'charset' => 'latin' ], [ 'family' => 'Akronim', 'weight' => 'regular, bold', 'charset' => 'latin' ], [ 'family' => 'Akronim', 'weight' => 'regular', 'charset' => 'latin,latin-ext' ], [ 'family' => 'Acme', 'weight' => 'regular', 'charset' => 'latin' ] ]; $result = []; foreach ($fonts as $row) { $row['weight'] = array_flip(preg_split('~, ?~', $row['weight'], 0, PREG_SPLIT_NO_EMPTY)); $row['charset'] = array_flip(preg_split('~, ?~', $row['charset'], 0, PREG_SPLIT_NO_EMPTY)); if (!isset($result[$row['family']])) { $result[$row['family']] = $row; } else { $result[$row['family']]['weight'] += $row['weight']; $result[$row['family']]['charset'] += $row['charset']; } } foreach ($result as &$row) { $row['weight'] = implode(',', array_keys($row['weight'])); $row['charset'] = implode(',', array_keys($row['charset'])); } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 47
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 47
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 47
2 jumps found. (Code = 125) Position 1 = 49, Position 2 = 65
Branch analysis from position: 49
2 jumps found. (Code = 126) Position 1 = 50, Position 2 = 65
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
Branch analysis from position: 47
filename:       /in/GTdQk
function name:  (null)
number of ops:  73
compiled vars:  !0 = $fonts, !1 = $result, !2 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   31     1        ASSIGN                                                       !1, <array>
   32     2      > FE_RESET_R                                           $5      !0, ->47
          3    > > FE_FETCH_R                                                   $5, !2, ->47
   33     4    >   INIT_FCALL                                                   'array_flip'
          5        INIT_FCALL                                                   'preg_split'
          6        SEND_VAL                                                     '%7E%2C+%3F%7E'
          7        FETCH_DIM_R                                          ~7      !2, 'weight'
          8        SEND_VAL                                                     ~7
          9        SEND_VAL                                                     0
         10        SEND_VAL                                                     1
         11        DO_ICALL                                             $8      
         12        SEND_VAR                                                     $8
         13        DO_ICALL                                             $9      
         14        ASSIGN_DIM                                                   !2, 'weight'
         15        OP_DATA                                                      $9
   34    16        INIT_FCALL                                                   'array_flip'
         17        INIT_FCALL                                                   'preg_split'
         18        SEND_VAL                                                     '%7E%2C+%3F%7E'
         19        FETCH_DIM_R                                          ~11     !2, 'charset'
         20        SEND_VAL                                                     ~11
         21        SEND_VAL                                                     0
         22        SEND_VAL                                                     1
         23        DO_ICALL                                             $12     
         24        SEND_VAR                                                     $12
         25        DO_ICALL                                             $13     
         26        ASSIGN_DIM                                                   !2, 'charset'
         27        OP_DATA                                                      $13
   35    28        FETCH_DIM_R                                          ~14     !2, 'family'
         29        ISSET_ISEMPTY_DIM_OBJ                             0  ~15     !1, ~14
         30        BOOL_NOT                                             ~16     ~15
         31      > JMPZ                                                         ~16, ->36
   36    32    >   FETCH_DIM_R                                          ~17     !2, 'family'
         33        ASSIGN_DIM                                                   !1, ~17
         34        OP_DATA                                                      !2
   35    35      > JMP                                                          ->46
   38    36    >   FETCH_DIM_R                                          ~19     !2, 'family'
         37        FETCH_DIM_R                                          ~22     !2, 'weight'
         38        FETCH_DIM_RW                                         $20     !1, ~19
         39        ASSIGN_DIM_OP                    +=               1          $20, 'weight'
         40        OP_DATA                                                      ~22
   39    41        FETCH_DIM_R                                          ~23     !2, 'family'
         42        FETCH_DIM_R                                          ~26     !2, 'charset'
         43        FETCH_DIM_RW                                         $24     !1, ~23
         44        ASSIGN_DIM_OP                    +=               1          $24, 'charset'
         45        OP_DATA                                                      ~26
   32    46    > > JMP                                                          ->3
         47    >   FE_FREE                                                      $5
   42    48      > FE_RESET_RW                                          $27     !1, ->65
         49    > > FE_FETCH_RW                                                  $27, !2, ->65
   43    50    >   INIT_FCALL                                                   'array_keys'
         51        FETCH_DIM_R                                          ~29     !2, 'weight'
         52        SEND_VAL                                                     ~29
         53        DO_ICALL                                             $30     
         54        FRAMELESS_ICALL_2                implode             ~31     '%2C', $30
         55        ASSIGN_DIM                                                   !2, 'weight'
         56        OP_DATA                                                      ~31
   44    57        INIT_FCALL                                                   'array_keys'
         58        FETCH_DIM_R                                          ~33     !2, 'charset'
         59        SEND_VAL                                                     ~33
         60        DO_ICALL                                             $34     
         61        FRAMELESS_ICALL_2                implode             ~35     '%2C', $34
         62        ASSIGN_DIM                                                   !2, 'charset'
         63        OP_DATA                                                      ~35
   42    64      > JMP                                                          ->49
         65    >   FE_FREE                                                      $27
   46    66        INIT_FCALL                                                   'var_export'
         67        INIT_FCALL                                                   'array_values'
         68        SEND_VAR                                                     !1
         69        DO_ICALL                                             $36     
         70        SEND_VAR                                                     $36
         71        DO_ICALL                                                     
         72      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.07 ms | 2075 KiB | 18 Q