You are here

protected function CSV::writeCommaSeparatedValues in Apigee Edge 8

Writes the CSV data into a string.

Parameters

array $data: CSV data.

Return value

string Encoded CSV.

1 call to CSV::writeCommaSeparatedValues()
CSV::encode in src/Plugin/ApigeeFieldStorageFormat/CSV.php
Encodes field data to the target format.

File

src/Plugin/ApigeeFieldStorageFormat/CSV.php, line 88

Class

CSV
CSV formatter for Apigee Edge field storage.

Namespace

Drupal\apigee_edge\Plugin\ApigeeFieldStorageFormat

Code

protected function writeCommaSeparatedValues(array $data) : string {
  $handle = fopen("php://temp", "w+");
  foreach ($data as $row) {
    fputcsv($handle, $row);
  }
  rewind($handle);
  $value = stream_get_contents($handle);
  fclose($handle);
  return $value;
}