92 $this->titles = array(
'dr',
'doctor',
'miss',
'misses',
'mr',
'mister',
'mrs',
'ms',
'judge',
'sir',
'madam',
'madame',
'AB',
'2ndLt',
'Amn',
'1stLt',
'A1C',
'Capt',
'SrA',
'Maj',
'SSgt',
'LtCol',
'TSgt',
'Col',
'BrigGen',
'1stSgt',
'MajGen',
'SMSgt',
'LtGen',
'1stSgt',
'Gen',
'CMSgt',
'1stSgt',
'CCMSgt',
'CMSAF',
'PVT',
'2LT',
'PV2',
'1LT',
'PFC',
'CPT',
'SPC',
'MAJ',
'CPL',
'LTC',
'SGT',
'COL',
'SSG',
'BG',
'SFC',
'MG',
'MSG',
'LTG',
'1SGT',
'GEN',
'SGM',
'CSM',
'SMA',
'WO1',
'WO2',
'WO3',
'WO4',
'WO5',
'ENS',
'SA',
'LTJG',
'SN',
'LT',
'PO3',
'LCDR',
'PO2',
'CDR',
'PO1',
'CAPT',
'CPO',
'RADM(LH)',
'SCPO',
'RADM(UH)',
'MCPO',
'VADM',
'MCPOC',
'ADM',
'MPCO-CG',
'CWO-2',
'CWO-3',
'CWO-4',
'Pvt',
'2ndLt',
'PFC',
'1stLt',
'LCpl',
'Capt',
'Cpl',
'Maj',
'Sgt',
'LtCol',
'SSgt',
'Col',
'GySgt',
'BGen',
'MSgt',
'MajGen',
'1stSgt',
'LtGen',
'MGySgt',
'Gen',
'SgtMaj',
'SgtMajMC',
'WO-1',
'CWO-2',
'CWO-3',
'CWO-4',
'CWO-5',
'ENS',
'SA',
'LTJG',
'SN',
'LT',
'PO3',
'LCDR',
'PO2',
'CDR',
'PO1',
'CAPT',
'CPO',
'RDML',
'SCPO',
'RADM',
'MCPO',
'VADM',
'MCPON',
'ADM',
'FADM',
'WO1',
'CWO2',
'CWO3',
'CWO4',
'CWO5');
94 $this->prefices = array(
'bon',
'ben',
'bin',
'da',
'dal',
'de',
'del',
'der',
'de',
'e',
'la',
'le',
'san',
'st',
'ste',
'van',
'vel',
'von');
95 $this->suffices = array(
'esq',
'esquire',
'jr',
'sr',
'2',
'i',
'ii',
'iii',
'iv',
'v',
'clu',
'chfc',
'cfp',
'md',
'phd');
97 $this->notParseable = FALSE;
100 if ( $initString !=
"" ) {
101 $this->fullName = $initString;
168 public function setFullName( $newFullName ) { $this->fullName = $newFullName; }
180 $needle = trim( strtolower( str_replace(
'.',
'', $needle ) ) );
181 return in_array( $needle, $haystack );
198 $this->notParseable = FALSE;
201 $pieces = explode(
',', preg_replace(
'/\s+/',
' ', trim( $this->fullName ) ) );
202 $numPieces = count( $pieces );
204 switch ( $numPieces ) {
208 $subPieces = explode(
' ', trim( $pieces[0] ) );
209 $numSubPieces = count( $subPieces );
210 for ( $i = 0; $i < $numSubPieces; $i++ ) {
211 $current = trim( $subPieces[$i] );
212 if ( $i < ($numSubPieces-1) ) {
213 $next = trim( $subPieces[$i+1] );
217 if ( $i == 0 && $this->
inArrayNorm( $current, $this->titles ) ) {
218 $this->title = $current;
221 if ( $this->first ==
"" ) {
222 $this->first = $current;
225 if ( $i == $numSubPieces-2 && ($next !=
"") && $this->
inArrayNorm( $next, $this->suffices ) ) {
226 if ( $this->last !=
"") {
227 $this->last .=
" ".$current;
229 $this->last = $current;
231 $this->suffix = $next;
234 if ( $i == $numSubPieces-1 ) {
235 if ( $this->last !=
"" ) {
236 $this->last .=
" ".$current;
238 $this->last = $current;
242 if ( $this->
inArrayNorm( $current, $this->prefices ) ) {
243 if ( $this->last !=
"" ) {
244 $this->last .=
" ".$current;
246 $this->last = $current;
250 if ( $next ==
'y' || $next ==
'Y' ) {
251 if ( $this->last !=
"" ) {
252 $this->last .=
" ".$current;
254 $this->last = $current;
258 if ( $this->last !=
"" ) {
259 $this->last .=
" ".$current;
262 if( $this->middle !=
"" ) {
263 $this->middle .=
" ".$current;
265 $this->middle = $current;
271 switch( $this->
inArrayNorm( $pieces[1], $this->suffices ) ) {
275 $subPieces = explode(
' ', trim( $pieces[0] ) );
276 $numSubPieces = count( $subPieces );
277 for ( $i = 0; $i < $numSubPieces; $i++ ) {
278 $current = trim( $subPieces[$i] );
279 if ( $i < ($numSubPieces-1) ) {
280 $next = trim( $subPieces[$i+1] );
284 if ( $i == 0 && $this->
inArrayNorm( $current, $this->titles ) ) {
285 $this->title = $current;
288 if ( $this->first ==
"" ) {
289 $this->first = $current;
292 if ( $i == $numSubPieces-1 ) {
293 if ( $this->last !=
"" ) {
294 $this->last .=
" ".$current;
296 $this->last = $current;
300 if ( $this->
inArrayNorm( $current, $this->prefices ) ) {
301 if ( $this->last !=
"" ) {
302 $this->last .=
" ".$current;
304 $this->last = $current;
308 if ( $next ==
'y' || $next ==
'Y' ) {
309 if ( $this->last !=
"" ) {
310 $this->last .=
" ".$current;
312 $this->last = $current;
316 if ( $this->last !=
"" ) {
317 $this->last .=
" ".$current;
320 if ( $this->middle !=
"" ) {
321 $this->middle .=
" ".$current;
323 $this->middle = $current;
326 $this->suffix = trim($pieces[1]);
327 for ( $i = 2; $i < $numPieces; $i++ ) {
328 $this->suffix .=
", ". trim( $pieces[$i] );
334 $subPieces = explode(
' ', trim( $pieces[1] ) );
335 $numSubPieces = count( $subPieces );
336 for ( $i = 0; $i < $numSubPieces; $i++ ) {
337 $current = trim( $subPieces[$i] );
338 if ( $i < ($numSubPieces-1) ) {
339 $next = trim( $subPieces[$i+1] );
343 if ( $i == 0 && $this->
inArrayNorm( $current, $this->titles ) ) {
344 $this->title = $current;
347 if ( $this->first ==
"" ) {
348 $this->first = $current;
351 if ( $i == $numSubPieces-2 && ($next !=
"") && $this->
inArrayNorm( $next, $this->suffices ) ) {
352 if ( $this->middle !=
"" ) {
353 $this->middle .=
" ".$current;
355 $this->middle = $current;
357 $this->suffix = $next;
360 if ( $i == $numSubPieces-1 && $this->
inArrayNorm( $current, $this->suffices ) ) {
361 $this->suffix = $current;
364 if ( $this->middle !=
"" ) {
365 $this->middle .=
" ".$current;
367 $this->middle = $current;
370 if( isset($pieces[2]) && $pieces[2] ) {
371 if ( $this->last ==
"" ) {
372 $this->suffix = trim( $pieces[2] );
373 for ($s = 3; $s < $numPieces; $s++) {
374 $this->suffix .=
", ". trim( $pieces[$s] );
377 for ($s = 2; $s < $numPieces; $s++) {
378 $this->suffix .=
", ". trim( $pieces[$s] );
382 $this->last = $pieces[0];
388 if ( $this->first ==
"" && $this->middle ==
"" && $this->last ==
"" ) {
389 $this->notParseable = TRUE;