Skip to main content
Skip table of contents

Building CSV Data

arrayToCsv

CODE
string arrayToCsv(array $data, string $delimiter = ',', string $enclosure = '"')

Parameters

$data: An array of values to convert to CSV

$delimiter: The character that is used to separate the values. The default is ','

$enclosure: Character used to encapsulate the data when the data contains the delimiter. The default is '“'

Return Values

Returns a string of delimited data or false on failure.

Example

PHP
/*
Create this CSV data from an Array

a,b,c,1,2,3
d,e,f,4,5,6
*/

$array = [
  ['a', 'b', 'c', 1, 2, 3],
  ['d', 'e', 'f', 4, 5, 6]
];
$csv = $this->arrayToCsv($array);
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.