You are here

public function ImporterService::getIndexOfNonNullValues in Hierarchical Taxonomy Import 8

This method returns the index on non-null values in Array.

Parameters

mixed $data:

Return value

mixed

1 call to ImporterService::getIndexOfNonNullValues()
ImporterService::import in src/services/ImporterService.php

File

src/services/ImporterService.php, line 134

Class

ImporterService
Class ImporterService.

Namespace

Drupal\hierarchical_taxonomy_importer\services

Code

public function getIndexOfNonNullValues($data) {

  // This gives the index of column in CSV that would be created as a new
  // taxonomy term.
  if (!empty($data) && !is_null($data)) {

    // Return the column after removing null or blanks values from a row.
    $keys = array_keys(array_diff($data, [
      " ",
      "",
    ]));
    return !empty($data) ? array_shift($keys) : 0;
  }
  return 0;
}