You are here

public function FormatRowToXml::trimmingKeys in Views OAI-PMH 8

Strip whitespace from the beginning and end of a array keys

Parameters

$array: array to trim keys

Return value

array

File

src/Service/FormatRowToXml.php, line 142

Class

FormatRowToXml

Namespace

Drupal\views_oai_pmh\Service

Code

public function trimmingKeys(&$array) {
  if (gettype($array) === 'array') {
    foreach ($array as $key => $value) {
      if (strpos($key, ' ') !== false) {
        $array[trim($key)] = $array[$key];
        unset($array[$key]);
      }
    }
    return array_map(array(
      $this,
      "trimmingKeys",
    ), $array);
  }
  else {
    return $array;
  }
}