From 651602f868e0e8322aaeedc156eb9fcb5085f624 Mon Sep 17 00:00:00 2001 From: Vladan Date: Fri, 29 Jun 2018 13:20:58 +0300 Subject: [PATCH] Keep the array order even if nickname exists --- parser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser.php b/parser.php index aa8d665..f5bf7a0 100644 --- a/parser.php +++ b/parser.php @@ -181,7 +181,7 @@ public function parse_name($full_name) { $has_nick = $this->get_nickname($full_name); if ($has_nick) { # Remove wrapper chars from around nickname - $name['nickname'] = mb_substr($has_nick, 1, (mb_strlen($has_nick) - 2)); + $nickname = mb_substr($has_nick, 1, (mb_strlen($has_nick) - 2)); # Remove the nickname from the full name $full_name = str_replace($has_nick, '', $full_name); # Get rid of consecutive spaces left by the removal @@ -297,6 +297,7 @@ public function parse_name($full_name) { $name['lname_base'] = trim($lname_base); $name['lname_compound'] = trim($lname_compound); $name['suffix'] = $suffix; + $name['nickname'] = isset($nickname) ? trim($nickname) : ''; return $name; }