You are here

public function HumanNameParser_Parser::getArray in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/Parser.php \HumanNameParser_Parser::getArray()

Returns all the parts of the name as an array.

Parameters

string $arrType: pass 'int' to get an integer-indexed array (default is associative)

Return value

array An array of the name-parts

1 call to HumanNameParser_Parser::getArray()
HumanNameParser_Parser::parseName in includes/Parser.php

File

includes/Parser.php, line 168

Class

HumanNameParser_Parser
Works with a Name object to parse out the parts of a name.

Code

public function getArray($arrType = 'assoc') {
  $arr = array();
  $arr['prefix'] = $this->leadingInit;
  $arr['firstname'] = $this->first;
  $arr['nicknames'] = $this->nicknames;
  $arr['initials'] = substr($this->middle, 0, 10);
  $arr['lastname'] = $this->last;
  $arr['suffix'] = $this->suffix;
  $arr['md5'] = md5(json_encode($arr));
  $arr['literal'] = $this->literal;
  if ($arrType == 'assoc') {
    return array_merge($this->nameParts, $arr);
  }
  elseif ($arrType == 'int') {
    return array_values($arr);
  }
  else {
    throw new Exception("Array must be associative ('assoc') or numeric ('num').");
  }
}