3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array ( array("Make" => "Volvo", "Color" => "red", "Quantity" => 18), array("Make" => "BMW", "Color" => "blue", "Quantity" => 13), array("Make" => "Saab", "Quantity" => 11), array("Make" => "Land Rover", "Color" => "green", "Quantity" => 15) ); echo "<pre>"; //below creates csv //$fp = fopen($cfilename, 'w'); $header = false; foreach ($data as $row) { if (empty($header)) //creates header, chr(9) makes tab delimited { $header = array_keys($row); //fputcsv($fp, $header, chr(9)); $header = array_flip($header); $header = array_map(function($header) { return "";}, $header); } var_dump(array_merge($header, $row)); } fclose($fp); return;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/fQ4Hm
function name:  (null)
number of ops:  35
compiled vars:  !0 = $data, !1 = $header, !2 = $row, !3 = $fp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        ECHO                                                     '%3Cpre%3E'
   12     2        ASSIGN                                                   !1, <false>
   13     3      > FE_RESET_R                                       $6      !0, ->29
          4    > > FE_FETCH_R                                               $6, !2, ->29
   15     5    >   ISSET_ISEMPTY_CV                                         !1
          6      > JMPZ                                                     ~7, ->21
   17     7    >   INIT_FCALL                                               'array_keys'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !1, $8
   19    11        INIT_FCALL                                               'array_flip'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !1, $10
   20    15        INIT_FCALL                                               'array_map'
         16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfQ4Hm%3A20%240'
         17        SEND_VAL                                                 ~12
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !1, $13
   22    21    >   INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'array_merge'
         23        SEND_VAR                                                 !1
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $15     
         26        SEND_VAR                                                 $15
         27        DO_ICALL                                                 
   13    28      > JMP                                                      ->4
         29    >   FE_FREE                                                  $6
   25    30        INIT_FCALL                                               'fclose'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                                 
   26    33      > RETURN                                                   null
         34*     > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FfQ4Hm%3A20%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fQ4Hm
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $header
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1      > RETURN                                                   ''
          2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfQ4Hm%3A20%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.85 ms | 1405 KiB | 25 Q