You are here

public static function CsvParser::createFromString in Feeds 8.3

Creates a CsvParser object from a string.

Parameters

string $string: The in-memory contents of a CSV file.

Return value

\Drupal\feeds\Component\CsvParser A new CsvParser object.

1 call to CsvParser::createFromString()
CsvParserTest::testAlternateLineEnding in tests/src/Unit/Component/CsvParserTest.php
Tests parsing a CSV source with several line endings.

File

src/Component/CsvParser.php, line 106

Class

CsvParser
Parses an RFC 4180 style CSV file.

Namespace

Drupal\feeds\Component

Code

public static function createFromString($string) {
  $previous = ini_set('auto_detect_line_endings', '1');
  $handle = fopen('php://temp', 'w+b');
  ini_set('auto_detect_line_endings', $previous);
  fwrite($handle, $string);
  fseek($handle, 0);
  return new static($handle);
}