You are here

public function HumanNameParser_Parser::getArray in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 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 136

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['leadingInit'] = $this->leadingInit;
  $arr['firstname'] = !empty($this->first) ? $this->first : $this->leadingInit;
  $arr['nicknames'] = $this->nicknames;
  $arr['initials'] = substr($this->middle, 0, 10);
  $arr['middlename'] = $this->middle;
  $arr['lastname'] = $this->last;
  $arr['suffix'] = $this->suffix;
  $arr['md5'] = biblio_calculate_contributor_hash($arr);
  $arr['literal'] = $this->literal;
  if ($arrType == 'assoc') {
    return array_merge($this->nameParts, $arr);
  }
  else {
    if ($arrType == 'int') {
      return array_values($arr);
    }
    else {
      throw new Exception("Array must be associative ('assoc') or numeric ('num').");
    }
  }
}