You are here

protected function FeedsCSVParser::parseHeader in Feeds 8.2

Get first line and use it for column names, convert them to lower case. Be aware that the $parser and iterator objects can be modified in this function since they are passed in by reference

Parameters

ParserCSV $parser:

ParserCSVIterator $iterator:

Return value

An array of lower-cased column names to use as keys for the parsed items.

1 call to FeedsCSVParser::parseHeader()
FeedsCSVParser::parse in lib/Drupal/feeds/Plugin/feeds/parser/FeedsCSVParser.php
Implements FeedsParser::parse().

File

lib/Drupal/feeds/Plugin/feeds/parser/FeedsCSVParser.php, line 78
Contains the FeedsCSVParser class.

Class

FeedsCSVParser
Defines a CSV feed parser.

Namespace

Drupal\feeds\Plugin\feeds\parser

Code

protected function parseHeader(ParserCSV $parser, ParserCSVIterator $iterator) {
  $parser
    ->setLineLimit(1);
  $rows = $parser
    ->parse($iterator);
  if (!count($rows)) {
    return FALSE;
  }
  $header = array_shift($rows);
  foreach ($header as $i => $title) {
    $header[$i] = trim(drupal_strtolower($title));
  }
  return $header;
}