3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_transpose(array $a) { $r = array(); foreach($a as $keyRow => $subArr) { foreach($subArr as $keyCol => $value) $r[$keyCol][$keyRow] = $value; } return $r; } $arr = [ 'Amministrativo ^25^9,11,2,10,18,4,7,^17,13,^0.75^0^0.25', 'Logico deduttive^7^^21,^0.75^0^-0.25', 'Situazionali^8^^20,^0.75^0^0.375', ]; foreach($arr as $i => $row){ $arr[$i] = explode('^',$row); } $arr = array_transpose($arr); foreach($arr as $i => $row){ $arr[$i] = implode(' ',$row); } var_export($arr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 11
filename:       /in/IdsDh
function name:  (null)
number of ops:  31
compiled vars:  !0 = $arr, !1 = $row, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   18     1      > FE_RESET_R                                       $4      !0, ->11
          2    > > FE_FETCH_R                                       ~5      $4, !1, ->11
          3    >   ASSIGN                                                   !2, ~5
   19     4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%5E'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $8      
          8        ASSIGN_DIM                                               !0, !2
          9        OP_DATA                                                  $8
   18    10      > JMP                                                      ->2
         11    >   FE_FREE                                                  $4
   22    12        INIT_FCALL                                               'array_transpose'
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !0, $9
   24    16      > FE_RESET_R                                       $11     !0, ->26
         17    > > FE_FETCH_R                                       ~12     $11, !1, ->26
         18    >   ASSIGN                                                   !2, ~12
   25    19        INIT_FCALL                                               'implode'
         20        SEND_VAL                                                 '+'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $15     
         23        ASSIGN_DIM                                               !0, !2
         24        OP_DATA                                                  $15
   24    25      > JMP                                                      ->17
         26    >   FE_FREE                                                  $11
   28    27        INIT_FCALL                                               'var_export'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function array_transpose:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/IdsDh
function name:  array_transpose
number of ops:  17
compiled vars:  !0 = $a, !1 = $r, !2 = $subArr, !3 = $keyRow, !4 = $value, !5 = $keyCol
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $7      !0, ->14
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->14
          4    >   ASSIGN                                                   !3, ~8
    6     5      > FE_RESET_R                                       $10     !2, ->12
          6    > > FE_FETCH_R                                       ~11     $10, !4, ->12
          7    >   ASSIGN                                                   !5, ~11
          8        FETCH_DIM_W                                      $13     !1, !5
          9        ASSIGN_DIM                                               $13, !3
         10        OP_DATA                                                  !4
         11      > JMP                                                      ->6
         12    >   FE_FREE                                                  $10
    5    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $7
    8    15      > RETURN                                                   !1
    9    16*     > RETURN                                                   null

End of function array_transpose

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.24 ms | 1009 KiB | 17 Q