function _grabFirstnameInitials in Bibliography Module 7
Same name and namespace in other branches
- 5 biblio.module \_grabFirstnameInitials()
- 6 biblio.contributors.inc \_grabFirstnameInitials()
- 7.2 includes/biblio.contributors.inc \_grabFirstnameInitials()
Grab firstname and initials which may be of form "A.B.C." or "A. B. C. " or " A B C " etc.
Parameters
$remainder:
2 calls to _grabFirstnameInitials()
File
- includes/
biblio.contributors.inc, line 606
Code
function _grabFirstnameInitials($remainder) {
$prefix = array();
$firstname = $initials = '';
$array = explode(" ", $remainder);
foreach ($array as $value) {
$first_char = drupal_substr($value, 0, 1);
if (ord($first_char) >= 97 && ord($first_char) <= 122) {
$prefix[] = $value;
}
elseif (preg_match("/[a-zA-Z]{2,}/", trim($value))) {
$firstname_array[] = trim($value);
}
else {
$initials_array[] = trim(str_replace(".", " ", trim($value)));
}
}
if (isset($initials_array)) {
$initials = implode(" ", $initials_array);
}
if (isset($firstname_array)) {
$firstname = implode(" ", $firstname_array);
}
if (!empty($prefix)) {
$prefix = implode(" ", $prefix);
}
return array(
$firstname,
$initials,
$prefix,
);
}