3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fieldArray = []; $fieldArray['field_val']['1'] = ['1']; $fieldArray['field_val']['2'] = ['1', '2', '3', '4']; $fieldArray['field_val']['3'] = ['5', '6', '7', '8']; $fieldArray['field_val']['4'] = ['9', '10', '11', '12']; $fieldArray['field_val']['5'] = ['30']; $temp = array_map(null, ...$fieldArray['field_val']); // transposing array foreach ($temp as $key => &$value) { foreach ($value as $key1 => &$value1) { if(empty($value1)){ // checking if empty // fetching key1 value from first array $value1 = $temp[0][$key1]; } } } echo implode("\n", array_map(function ($value) { // replace with br if web return implode(",", $value); }, $temp));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 24, Position 2 = 37
Branch analysis from position: 24
2 jumps found. (Code = 126) Position 1 = 25, Position 2 = 37
Branch analysis from position: 25
2 jumps found. (Code = 125) Position 1 = 27, Position 2 = 35
Branch analysis from position: 27
2 jumps found. (Code = 126) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 34
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 35
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/tXeb4
function name:  (null)
number of ops:  49
compiled vars:  !0 = $fieldArray, !1 = $temp, !2 = $value, !3 = $key, !4 = $value1, !5 = $key1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        FETCH_DIM_W                                      $7      !0, 'field_val'
          2        ASSIGN_DIM                                               $7, 1
          3        OP_DATA                                                  <array>
    4     4        FETCH_DIM_W                                      $9      !0, 'field_val'
          5        ASSIGN_DIM                                               $9, 2
          6        OP_DATA                                                  <array>
    5     7        FETCH_DIM_W                                      $11     !0, 'field_val'
          8        ASSIGN_DIM                                               $11, 3
          9        OP_DATA                                                  <array>
    6    10        FETCH_DIM_W                                      $13     !0, 'field_val'
         11        ASSIGN_DIM                                               $13, 4
         12        OP_DATA                                                  <array>
    7    13        FETCH_DIM_W                                      $15     !0, 'field_val'
         14        ASSIGN_DIM                                               $15, 5
         15        OP_DATA                                                  <array>
    8    16        INIT_FCALL                                               'array_map'
         17        SEND_VAL                                                 null
         18        FETCH_DIM_R                                      ~17     !0, 'field_val'
         19        SEND_UNPACK                                              ~17
         20        CHECK_UNDEF_ARGS                                         
         21        DO_ICALL                                         $18     
         22        ASSIGN                                                   !1, $18
    9    23      > FE_RESET_RW                                      $20     !1, ->37
         24    > > FE_FETCH_RW                                      ~21     $20, !2, ->37
         25    >   ASSIGN                                                   !3, ~21
   10    26      > FE_RESET_RW                                      $23     !2, ->35
         27    > > FE_FETCH_RW                                      ~24     $23, !4, ->35
         28    >   ASSIGN                                                   !5, ~24
   11    29        ISSET_ISEMPTY_CV                                         !4
         30      > JMPZ                                                     ~26, ->34
   13    31    >   FETCH_DIM_R                                      ~27     !1, 0
         32        FETCH_DIM_R                                      ~28     ~27, !5
         33        ASSIGN                                                   !4, ~28
   10    34    > > JMP                                                      ->27
         35    >   FE_FREE                                                  $23
    9    36      > JMP                                                      ->24
         37    >   FE_FREE                                                  $20
   17    38        INIT_FCALL                                               'implode'
         39        SEND_VAL                                                 '%0A'
         40        INIT_FCALL                                               'array_map'
         41        DECLARE_LAMBDA_FUNCTION                          ~30     [0]
   19    42        SEND_VAL                                                 ~30
         43        SEND_VAR                                                 !1
   17    44        DO_ICALL                                         $31     
   19    45        SEND_VAR                                                 $31
   17    46        DO_ICALL                                         $32     
   19    47        ECHO                                                     $32
         48      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tXeb4
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '%2C'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   19     6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.64 ms | 1004 KiB | 15 Q