3v4l.org

run code in 300+ PHP versions simultaneously
<?php $font_f = [ ['font' => 'Poppins', 'lang' => 'Hindi, English', 'weight' => '700, 700i'], ['font' => 'Lora', 'lang' => 'Vietnamese, Japanese', 'weight' => '200, 300, 400, 400i'], ['font' => 'Noto Sans', 'lang' => 'Punjabi, Latin, Hindi', 'weight' => '200, 200i, 300, 300i, 400, 500'], ['font' => 'Lora', 'lang' => 'Greek, Roman, Vietnamese', 'weight' => '400, 400i, 500, 500b'], ]; $result = []; foreach ($font_f as $row) { $f = $row['font']; if (!isset($result[$f])) { $result[$f] = $row; continue; } // append, split, merge, de-duplicate, sort, join foreach(["lang", "weight"] as $col) { $result[$f][$col] .= ', ' . $row[$col]; $result[$f][$col] = array_unique(explode(', ', trim($result[$f][$col], ', '))); sort($result[$f][$col]); $result[$f][$col] = implode(', ', $result[$f][$col]); } } ksort($result); // sort rows by font name var_export(array_values($result)); // print without temporary grouping keys
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 52
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 52
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 50
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 50
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 50
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
filename:       /in/qBRjb
function name:  (null)
number of ops:  63
compiled vars:  !0 = $font_f, !1 = $result, !2 = $row, !3 = $f, !4 = $col
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2      > FE_RESET_R                                       $7      !0, ->52
          3    > > FE_FETCH_R                                               $7, !2, ->52
   12     4    >   FETCH_DIM_R                                      ~8      !2, 'font'
          5        ASSIGN                                                   !3, ~8
   13     6        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !1, !3
          7        BOOL_NOT                                         ~11     ~10
          8      > JMPZ                                                     ~11, ->12
   14     9    >   ASSIGN_DIM                                               !1, !3
         10        OP_DATA                                                  !2
   15    11      > JMP                                                      ->3
   18    12    > > FE_RESET_R                                       $13     <array>, ->50
         13    > > FE_FETCH_R                                               $13, !4, ->50
   19    14    >   FETCH_DIM_R                                      ~16     !2, !4
         15        CONCAT                                           ~17     '%2C+', ~16
         16        FETCH_DIM_RW                                     $14     !1, !3
         17        ASSIGN_DIM_OP                .=               8          $14, !4
         18        OP_DATA                                                  ~17
   20    19        INIT_FCALL                                               'array_unique'
         20        INIT_FCALL                                               'explode'
         21        SEND_VAL                                                 '%2C+'
         22        INIT_FCALL                                               'trim'
         23        FETCH_DIM_R                                      ~20     !1, !3
         24        FETCH_DIM_R                                      ~21     ~20, !4
         25        SEND_VAL                                                 ~21
         26        SEND_VAL                                                 '%2C+'
         27        DO_ICALL                                         $22     
         28        SEND_VAR                                                 $22
         29        DO_ICALL                                         $23     
         30        SEND_VAR                                                 $23
         31        DO_ICALL                                         $24     
         32        FETCH_DIM_W                                      $18     !1, !3
         33        ASSIGN_DIM                                               $18, !4
         34        OP_DATA                                                  $24
   21    35        INIT_FCALL                                               'sort'
         36        FETCH_DIM_W                                      $25     !1, !3
         37        FETCH_DIM_W                                      $26     $25, !4
         38        SEND_REF                                                 $26
         39        DO_ICALL                                                 
   22    40        INIT_FCALL                                               'implode'
         41        SEND_VAL                                                 '%2C+'
         42        FETCH_DIM_R                                      ~30     !1, !3
         43        FETCH_DIM_R                                      ~31     ~30, !4
         44        SEND_VAL                                                 ~31
         45        DO_ICALL                                         $32     
         46        FETCH_DIM_W                                      $28     !1, !3
         47        ASSIGN_DIM                                               $28, !4
         48        OP_DATA                                                  $32
   18    49      > JMP                                                      ->13
         50    >   FE_FREE                                                  $13
   11    51      > JMP                                                      ->3
         52    >   FE_FREE                                                  $7
   25    53        INIT_FCALL                                               'ksort'
         54        SEND_REF                                                 !1
         55        DO_ICALL                                                 
   26    56        INIT_FCALL                                               'var_export'
         57        INIT_FCALL                                               'array_values'
         58        SEND_VAR                                                 !1
         59        DO_ICALL                                         $34     
         60        SEND_VAR                                                 $34
         61        DO_ICALL                                                 
         62      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.17 ms | 1010 KiB | 21 Q