3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = [ 'NUM' => [ 101, 102, 103, ], 'NOM' => [ 'Smith', 'Robson', 'Daniels', ], 'PRENOM' => [ 'Alice', 'Bob', 'Charlie', ], ]; // Grab all possible outer keys $outerKeys = array_keys($data); // Make sure all child arrays are the same size $innerCount = null; foreach($outerKeys as $key) { // Also make sure that we've got a list so that we don't have to keep // track of child keys. For a 7.x polyfill see // https://www.php.net/manual/en/function.array-is-list.php if(!array_is_list($data[$key])){ throw new RuntimeException('Child array is not a list'); } // Count the first item if(null === $innerCount){ $innerCount = count($data[$key]); continue; } // Compare the known count with the current child array if($innerCount !== count($data[$key])){ throw new RuntimeException('Child array does not have equal item count'); } } $lines = []; for($idx = 0; $idx < $innerCount; $idx++){ $buf = []; foreach($outerKeys as $key){ $buf[] = $key . ':' . $data[$key][$idx]; } $lines[] = implode(' ', $buf); } echo implode(PHP_EOL, $lines);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 33
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 33
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 37
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 47
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 47
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 37
Branch analysis from position: 54
Branch analysis from position: 37
Branch analysis from position: 47
Branch analysis from position: 33
filename:       /in/XZbgL
function name:  (null)
number of ops:  57
compiled vars:  !0 = $data, !1 = $outerKeys, !2 = $innerCount, !3 = $key, !4 = $lines, !5 = $idx, !6 = $buf
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   22     1        INIT_FCALL                                                   'array_keys'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $8      
          4        ASSIGN                                                       !1, $8
   25     5        ASSIGN                                                       !2, null
   26     6      > FE_RESET_R                                           $11     !1, ->33
          7    > > FE_FETCH_R                                                   $11, !3, ->33
   31     8    >   INIT_FCALL                                                   'array_is_list'
          9        FETCH_DIM_R                                          ~12     !0, !3
         10        SEND_VAL                                                     ~12
         11        DO_ICALL                                             $13     
         12        BOOL_NOT                                             ~14     $13
         13      > JMPZ                                                         ~14, ->18
   32    14    >   NEW                                                  $15     'RuntimeException'
         15        SEND_VAL_EX                                                  'Child+array+is+not+a+list'
         16        DO_FCALL                                          0          
         17      > THROW                                             0          $15
   36    18    >   TYPE_CHECK                                        2          !2
         19      > JMPZ                                                         ~17, ->24
   37    20    >   FETCH_DIM_R                                          ~18     !0, !3
         21        COUNT                                                ~19     ~18
         22        ASSIGN                                                       !2, ~19
   38    23      > JMP                                                          ->7
   42    24    >   FETCH_DIM_R                                          ~21     !0, !3
         25        COUNT                                                ~22     ~21
         26        IS_NOT_IDENTICAL                                             !2, ~22
         27      > JMPZ                                                         ~23, ->32
   43    28    >   NEW                                                  $24     'RuntimeException'
         29        SEND_VAL_EX                                                  'Child+array+does+not+have+equal+item+count'
         30        DO_FCALL                                          0          
         31      > THROW                                             0          $24
   26    32    > > JMP                                                          ->7
         33    >   FE_FREE                                                      $11
   47    34        ASSIGN                                                       !4, <array>
   48    35        ASSIGN                                                       !5, 0
         36      > JMP                                                          ->52
   49    37    >   ASSIGN                                                       !6, <array>
   50    38      > FE_RESET_R                                           $29     !1, ->47
         39    > > FE_FETCH_R                                                   $29, !3, ->47
   51    40    >   CONCAT                                               ~31     !3, '%3A'
         41        FETCH_DIM_R                                          ~32     !0, !3
         42        FETCH_DIM_R                                          ~33     ~32, !5
         43        CONCAT                                               ~34     ~31, ~33
         44        ASSIGN_DIM                                                   !6
         45        OP_DATA                                                      ~34
   50    46      > JMP                                                          ->39
         47    >   FE_FREE                                                      $29
   53    48        FRAMELESS_ICALL_2                implode             ~36     '+', !6
         49        ASSIGN_DIM                                                   !4
         50        OP_DATA                                                      ~36
   48    51        PRE_INC                                                      !5
         52    >   IS_SMALLER                                                   !5, !2
         53      > JMPNZ                                                        ~38, ->37
   56    54    >   FRAMELESS_ICALL_2                implode             ~39     '%0A', !4
         55        ECHO                                                         ~39
         56      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.71 ms | 1881 KiB | 17 Q