LLMS_Meta_Box_Voucher_Export::array_to_csv( $data,  $delimiter = ',',  $enclosure = '"' )


Source Source

File: includes/admin/post-types/meta-boxes/class.llms.meta.box.voucher.export.php

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
public static function array_to_csv( $data, $delimiter = ',', $enclosure = '"' ) {
 
    $handle   = fopen( 'php://temp', 'r+' );
    $contents = '';
 
    $names = array();
 
    foreach ( $data[0] as $name => $item ) {
        $names[] = $name;
    }
 
    fputcsv( $handle, $names, $delimiter, $enclosure );
 
    foreach ( $data as $line ) {
        fputcsv( $handle, $line, $delimiter, $enclosure );
    }
    rewind( $handle );
    while ( ! feof( $handle ) ) {
        $contents .= fread( $handle, 8192 );
    }
    fclose( $handle );
    return $contents;
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.