public function PARSECREATORS::grabFirstnameInitials in Bibliography Module 7
Same name and namespace in other branches
- 5 bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
- 6.2 modules/bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
- 6 bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
- 7.3 plugins/biblio_style/bibtex/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
- 7.2 modules/bibtexParse/PARSECREATORS.php \PARSECREATORS::grabFirstnameInitials()
Grab firstname and initials which may be of form "A.B.C." or "A. B. C. " or " A B C " etc.
1 call to PARSECREATORS::grabFirstnameInitials()
- PARSECREATORS::parseAuthor in modules/
bibtexParse/ PARSECREATORS.php - Create writer arrays from bibtex input.
File
- modules/
bibtexParse/ PARSECREATORS.php, line 288 - Classes Creators and PARSECREATORS.
Class
- PARSECREATORS
- Released through http://bibliophile.sourceforge.net under the GPL licence. Do whatever you like with this -- some credit to the author(s) would be appreciated.
Code
public function grabFirstnameInitials($remainder) {
$firstname = $initials = '';
$array = preg_split(" ", $remainder);
foreach ($array as $value) {
$firstChar = substr($value, 0, 1);
if (ord($firstChar) >= 97 && ord($firstChar) <= 122) {
$this->prefix[] = $value;
}
elseif (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,
);
}