You are here

function PARSECREATORS::grabFirstnameInitials in Bibliography Module 5

Same name and namespace in other branches
  1. 6.2 modules/bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
  2. 6 bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
  3. 7.3 plugins/biblio_style/bibtex/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
  4. 7 modules/bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
  5. 7.2 modules/bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
1 call to PARSECREATORS::grabFirstnameInitials()
PARSECREATORS::parse in bibtexParse/PARSECREATORS.php

File

bibtexParse/PARSECREATORS.php, line 97

Class

PARSECREATORS

Code

function grabFirstnameInitials($remainder) {
  $firstname = $initials = '';
  $array = split(" ", $remainder);
  foreach ($array as $value) {
    $firstChar = substr($value, 0, 1);
    if (ord($firstChar) >= 97 && ord($firstChar) <= 122) {
      $this->prefix[] = $value;
    }
    else {
      if (preg_match("/[a-zA-Z]{2,}/", trim($value))) {
        $firstnameArray[] = trim($value);
      }
      else {
        $initialsArray[] = str_replace(".", " ", trim($value));
      }
    }
  }
  if (isset($initialsArray)) {
    foreach ($initialsArray as $initial) {
      $initials .= ' ' . trim($initial);
    }
  }
  if (isset($firstnameArray)) {
    $firstname = join(" ", $firstnameArray);
  }
  return array(
    $firstname,
    $initials,
  );
}