function _grabFirstnameInitials in Bibliography Module 6
Same name and namespace in other branches
- 5 biblio.module \_grabFirstnameInitials()
- 7 includes/biblio.contributors.inc \_grabFirstnameInitials()
- 7.2 includes/biblio.contributors.inc \_grabFirstnameInitials()
Parameters
$remainder:
Return value
unknown_type
1 call to _grabFirstnameInitials()
File
- ./
biblio.contributors.inc, line 341
Code
function _grabFirstnameInitials($remainder) {
$prefix = array();
$firstname = $initials = '';
$array = explode(" ", $remainder);
foreach ($array as $value) {
$firstChar = drupal_substr($value, 0, 1);
if (ord($firstChar) >= 97 && ord($firstChar) <= 122) {
$prefix[] = $value;
}
else {
if (preg_match("/[a-zA-Z]{2,}/", trim($value))) {
$firstnameArray[] = trim($value);
}
else {
$initialsArray[] = trim(str_replace(".", " ", trim($value)));
}
}
}
if (isset($initialsArray)) {
$initials = implode(" ", $initialsArray);
}
if (isset($firstnameArray)) {
$firstname = implode(" ", $firstnameArray);
}
if (!empty($prefix)) {
$prefix = implode(" ", $prefix);
}
return array(
$firstname,
$initials,
$prefix,
);
}