3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fputcsvdata($dataArray,$delimiter,$enclosure) { // Write a line to a file // $filePointer = the file resource to write to // $dataArray = the data to write out // $delimeter = the field separator // Build the string $string = ""; // No leading delimiter $writeDelimiter = FALSE; foreach($dataArray as $dataElement) { // Replaces a double quote with two double quotes $dataElement=str_replace("\"", "\"\"", $dataElement); // Adds a delimiter before each field (except the first) if($writeDelimiter) $string .= $delimiter; if (!is_numeric($dataElement) && !empty($dataElement)){ // Encloses each field with $enclosure and adds it to the string $string .= $enclosure . $dataElement . $enclosure; } else { $string .= $dataElement; } // Delimiters are used every time except the first. $writeDelimiter = TRUE; } // end foreach($dataArray as $dataElement) // Append new line $string .= "\n"; return $string; } $data = array(4187561,0,'',46,'','','','2013-07-12 12:44:26',1,'/u4187561'); //$data = array('this','is some', 'csv "stuff", you know.', 1, ''); var_dump(fputcsvdata($data, ',', '"')); //$out = fopen('php://output', 'w'); //fputcsv($out, $data); //fclose($out); var_dump(time());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hgZLa
function name:  (null)
number of ops:  15
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   ASSIGN                                                   !0, <array>
   43     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'fputcsvdata'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%2C'
          5        SEND_VAL                                                 '%22'
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   47     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'time'
         11        DO_ICALL                                         $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function fputcsvdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 31
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 31
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 23
Branch analysis from position: 15
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/hgZLa
function name:  fputcsvdata
number of ops:  35
compiled vars:  !0 = $dataArray, !1 = $delimiter, !2 = $enclosure, !3 = $string, !4 = $writeDelimiter, !5 = $dataElement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   10     3        ASSIGN                                                   !3, ''
   13     4        ASSIGN                                                   !4, <false>
   14     5      > FE_RESET_R                                       $8      !0, ->31
          6    > > FE_FETCH_R                                               $8, !5, ->31
   17     7    >   INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '%22'
          9        SEND_VAL                                                 '%22%22'
         10        SEND_VAR                                                 !5
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !5, $9
   20    13      > JMPZ                                                     !4, ->15
         14    >   ASSIGN_OP                                     8          !3, !1
   22    15    >   INIT_FCALL                                               'is_numeric'
         16        SEND_VAR                                                 !5
         17        DO_ICALL                                         $12     
         18        BOOL_NOT                                         ~13     $12
         19      > JMPZ_EX                                          ~13     ~13, ->23
         20    >   ISSET_ISEMPTY_CV                                 ~14     !5
         21        BOOL_NOT                                         ~15     ~14
         22        BOOL                                             ~13     ~15
         23    > > JMPZ                                                     ~13, ->28
   24    24    >   CONCAT                                           ~16     !2, !5
         25        CONCAT                                           ~17     ~16, !2
         26        ASSIGN_OP                                     8          !3, ~17
         27      > JMP                                                      ->29
   26    28    >   ASSIGN_OP                                     8          !3, !5
   30    29    >   ASSIGN                                                   !4, <true>
   14    30      > JMP                                                      ->6
         31    >   FE_FREE                                                  $8
   34    32        ASSIGN_OP                                     8          !3, '%0A'
   37    33      > RETURN                                                   !3
   38    34*     > RETURN                                                   null

End of function fputcsvdata

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
200.27 ms | 1403 KiB | 22 Q