public function HumanNameParser_Name::flip in Bibliography Module 7
Same name and namespace in other branches
- 6.2 includes/Name.php \HumanNameParser_Name::flip()
Flips the front and back parts of a name with one another. Front and back are determined by a specified character somewhere in the middle of the string.
Parameters
string $flipAroundChar: the character(s) demarcating the two halves you want to flip.
Return value
Bool True on success.
File
- includes/
Name.php, line 84
Class
- HumanNameParser_Name
- Does cutting and matching stuff with a name string. Note that the string has to be UTF8-encoded.
Code
public function flip($flipAroundChar) {
$substrings = preg_split("/{$flipAroundChar}/u", $this->str);
if (count($substrings) == 2) {
$this->str = $substrings[1] . " " . $substrings[0];
$this
->norm();
}
elseif (count($substrings) > 2) {
throw new Exception("Can't flip around multiple '{$flipAroundChar}' characters in: '{$this->str}'.");
}
// If there's 1 or 0 $flipAroundChar found.
return TRUE;
}