3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate_csv_data($data,$use_key=false,$delm=',') { $output = NULL; if(is_array($data)) { if($use_key == false) { if(isset($data[0]) && is_array($data[0])) { foreach($data as $key) { $output .= implode($delm,$key); $output .= "\n"; } } else { $output .= implode("$delm", $data)."\n"; } } else { foreach($data as $key => $value) { $output .= "$key{$delm}$value\n"; } } } else { $output = $data; } if(empty($output)) { trigger_error('OUTPUT WAS EMPTY!', E_USER_ERROR); return false; } return $output; } $data = array('this','is some', 'csv "stuff", you know.'); var_dump(generate_csv_data($data)); $out = fopen('php://output', 'w'); fputcsv($out, $data); fclose($out);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HGVpl
function name:  (null)
number of ops:  20
compiled vars:  !0 = $data, !1 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'generate_csv_data'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        SEND_VAR                                                 $3
          6        DO_ICALL                                                 
   32     7        INIT_FCALL                                               'fopen'
          8        SEND_VAL                                                 'php%3A%2F%2Foutput'
          9        SEND_VAL                                                 'w'
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !1, $5
   33    12        INIT_FCALL                                               'fputcsv'
         13        SEND_VAR                                                 !1
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
   34    16        INIT_FCALL                                               'fclose'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function generate_csv_data:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 44
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 33
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 52
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 13
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 42
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 42
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 42
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 52
Branch analysis from position: 47
Branch analysis from position: 52
filename:       /in/HGVpl
function name:  generate_csv_data
number of ops:  54
compiled vars:  !0 = $data, !1 = $use_key, !2 = $delm, !3 = $output, !4 = $key, !5 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
          2        RECV_INIT                                        !2      '%2C'
    3     3        ASSIGN                                                   !3, null
    4     4        TYPE_CHECK                                  128          !0
          5      > JMPZ                                                     ~7, ->44
    5     6    >   BOOL_NOT                                         ~8      !1
          7      > JMPZ                                                     ~8, ->33
    6     8    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !0, 0
          9      > JMPZ_EX                                          ~9      ~9, ->13
         10    >   FETCH_DIM_R                                      ~10     !0, 0
         11        TYPE_CHECK                                  128  ~11     ~10
         12        BOOL                                             ~9      ~11
         13    > > JMPZ                                                     ~9, ->25
    7    14    > > FE_RESET_R                                       $12     !0, ->23
         15    > > FE_FETCH_R                                               $12, !4, ->23
    8    16    >   INIT_FCALL                                               'implode'
         17        SEND_VAR                                                 !2
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                         $13     
         20        ASSIGN_OP                                     8          !3, $13
    9    21        ASSIGN_OP                                     8          !3, '%0A'
    7    22      > JMP                                                      ->15
         23    >   FE_FREE                                                  $12
         24      > JMP                                                      ->32
   12    25    >   INIT_FCALL                                               'implode'
         26        CAST                                          6  ~16     !2
         27        SEND_VAL                                                 ~16
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                         $17     
         30        CONCAT                                           ~18     $17, '%0A'
         31        ASSIGN_OP                                     8          !3, ~18
         32    > > JMP                                                      ->43
   15    33    > > FE_RESET_R                                       $20     !0, ->42
         34    > > FE_FETCH_R                                       ~21     $20, !5, ->42
         35    >   ASSIGN                                                   !4, ~21
   16    36        ROPE_INIT                                     4  ~24     !4
         37        ROPE_ADD                                      1  ~24     ~24, !2
         38        ROPE_ADD                                      2  ~24     ~24, !5
         39        ROPE_END                                      3  ~23     ~24, '%0A'
         40        ASSIGN_OP                                     8          !3, ~23
   15    41      > JMP                                                      ->34
         42    >   FE_FREE                                                  $20
         43    > > JMP                                                      ->45
   20    44    >   ASSIGN                                                   !3, !0
   22    45    >   ISSET_ISEMPTY_CV                                         !3
         46      > JMPZ                                                     ~28, ->52
   23    47    >   INIT_FCALL                                               'trigger_error'
         48        SEND_VAL                                                 'OUTPUT+WAS+EMPTY%21'
         49        SEND_VAL                                                 256
         50        DO_ICALL                                                 
   24    51      > RETURN                                                   <false>
   26    52    > > RETURN                                                   !3
   27    53*     > RETURN                                                   null

End of function generate_csv_data

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.47 ms | 1407 KiB | 26 Q