You are here

protected function CSV::readCommaSeparatedValues in Apigee Edge 8

Reads the CSV data from a string.

Parameters

string $data: CSV data.

Return value

array Decoded CSV.

1 call to CSV::readCommaSeparatedValues()
CSV::decode in src/Plugin/ApigeeFieldStorageFormat/CSV.php
Decodes field data from the target format.

File

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

Class

CSV
CSV formatter for Apigee Edge field storage.

Namespace

Drupal\apigee_edge\Plugin\ApigeeFieldStorageFormat

Code

protected function readCommaSeparatedValues(string $data) : array {
  $handle = fopen("php://temp", "r+");
  fwrite($handle, $data);
  rewind($handle);
  $result = [];
  while ($cols = fgetcsv($handle, 0)) {
    $result[] = $cols;
  }
  fclose($handle);
  return $result;
}