3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '2020-01; Starter1; 11,4% 2020-01; Starter2; 6,9% 2020-01; Starter3; 9,5% 2020-01; Starter4; 11,1% 2020-02; Starter1; 5,8% 2020-02; Starter2; 5,8% 2020-02; Starter3; 10,0% 2020-02; Starter4; 6,4%'; // normalise and group data $result = []; foreach(str_getcsv($str, "\n") as $row){ $row = array_map('trim', str_getcsv($row, ";")); $result[$row[0]][$row[1]] = $row[2]; } // loop over to specification echo 'Year; Starter1; Starter2; Starter3; Starter4'.PHP_EOL; foreach ($result as $year => $row) { echo $year.'; '; foreach ($row as $key => $col) echo $col.";".str_repeat(' ', (($v = strlen($key)-(strlen($col)-1)) && $v > 0) ? $v : 0); echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 24
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 57
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 57
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 54
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 54
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 45
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 54
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 24
filename:       /in/11VaW
function name:  (null)
number of ops:  59
compiled vars:  !0 = $str, !1 = $result, !2 = $row, !3 = $year, !4 = $col, !5 = $key, !6 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '2020-01%3B+Starter1%3B+11%2C4%25%0A2020-01%3B+Starter2%3B+6%2C9%25%0A2020-01%3B+Starter3%3B+9%2C5%25%0A2020-01%3B+Starter4%3B+11%2C1%25%0A2020-02%3B+Starter1%3B+5%2C8%25%0A2020-02%3B+Starter2%3B+5%2C8%25%0A2020-02%3B+Starter3%3B+10%2C0%25%0A2020-02%3B+Starter4%3B+6%2C4%25'
   12     1        ASSIGN                                                   !1, <array>
   13     2        INIT_FCALL                                               'str_getcsv'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%0A'
          5        DO_ICALL                                         $9      
          6      > FE_RESET_R                                       $10     $9, ->24
          7    > > FE_FETCH_R                                               $10, !2, ->24
   14     8    >   INIT_FCALL                                               'array_map'
          9        SEND_VAL                                                 'trim'
         10        INIT_FCALL                                               'str_getcsv'
         11        SEND_VAR                                                 !2
         12        SEND_VAL                                                 '%3B'
         13        DO_ICALL                                         $11     
         14        SEND_VAR                                                 $11
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !2, $12
   15    17        FETCH_DIM_R                                      ~14     !2, 0
         18        FETCH_DIM_R                                      ~16     !2, 1
         19        FETCH_DIM_R                                      ~18     !2, 2
         20        FETCH_DIM_W                                      $15     !1, ~14
         21        ASSIGN_DIM                                               $15, ~16
         22        OP_DATA                                                  ~18
   13    23      > JMP                                                      ->7
         24    >   FE_FREE                                                  $10
   19    25        ECHO                                                     'Year%3B++++Starter1%3B+Starter2%3B+Starter3%3B+Starter4%0A'
   20    26      > FE_RESET_R                                       $19     !1, ->57
         27    > > FE_FETCH_R                                       ~20     $19, !2, ->57
         28    >   ASSIGN                                                   !3, ~20
   21    29        CONCAT                                           ~22     !3, '%3B+'
         30        ECHO                                                     ~22
   22    31      > FE_RESET_R                                       $23     !2, ->54
         32    > > FE_FETCH_R                                       ~24     $23, !4, ->54
         33    >   ASSIGN                                                   !5, ~24
   23    34        CONCAT                                           ~26     !4, '%3B'
         35        INIT_FCALL                                               'str_repeat'
         36        SEND_VAL                                                 '+'
         37        STRLEN                                           ~27     !5
         38        STRLEN                                           ~28     !4
         39        SUB                                              ~29     ~28, 1
         40        SUB                                              ~30     ~27, ~29
         41        ASSIGN                                           ~31     !6, ~30
         42      > JMPZ_EX                                          ~31     ~31, ->45
         43    >   IS_SMALLER                                       ~32     0, !6
         44        BOOL                                             ~31     ~32
         45    > > JMPZ                                                     ~31, ->48
         46    >   QM_ASSIGN                                        ~33     !6
         47      > JMP                                                      ->49
         48    >   QM_ASSIGN                                        ~33     0
         49    >   SEND_VAL                                                 ~33
         50        DO_ICALL                                         $34     
         51        CONCAT                                           ~35     ~26, $34
         52        ECHO                                                     ~35
   22    53      > JMP                                                      ->32
         54    >   FE_FREE                                                  $23
   24    55        ECHO                                                     '%0A'
   20    56      > JMP                                                      ->27
         57    >   FE_FREE                                                  $19
   25    58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.58 ms | 1405 KiB | 19 Q