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

	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.