protected static function is_suffix($word, $name) {
    # Ignore periods, normalize case
    $word = str_replace('.', '', strtolower($word));
    # Search the array for our word
    $line_match = array_search($word, array_map('strtolower', self::$dict['suffixes']['line']));
    $prof_match = array_search($word, array_map('strtolower', self::$dict['suffixes']['prof']));
    # Break out for professional suffix matches first
    if ($prof_match !== false) {
      return self::$dict['suffixes']['prof'][$prof_match];
    }
    # Now test our edge cases based on lineage
    if ($line_match !== false) {
      # Store our match
      $matched_case = self::$dict['suffixes']['line'][$line_match];
      # Remove it from the array
      $temp_array = self::$dict['suffixes']['line'];
      unset($temp_array[$line_match]);
      # Make sure we're dealing with the suffix and not a surname
      if ($word == 'senior' || $word == 'junior') {
        # If name is Joshua Senior, it's pretty likely that Senior is the surname
        # However, if the name is Joshua Jones Senior, then it's likely a suffix
        if (str_word_count($name) < 3) {
          return false;
        }
        # If the word Junior or Senior is contained, but so is some other
        # lineage suffix, then the word is likely a surname and not a suffix
        foreach ($temp_array as $suffix) {
          if (preg_match("/\b".$suffix."\b/i", $name)) {
            return false;
          }
        }
      }
      return $matched_case;
    }
    return false;
  }
protected static function is_suffix($word, $name) {
    # Ignore periods, normalize case
    $word = str_replace('.', '', strtolower($word));
    # Search the array for our word
    $line_match = array_search($word, array_map('strtolower', self::$dict['suffixes']['line']));
    $prof_match = array_search($word, array_map('strtolower', self::$dict['suffixes']['prof']));
    # Break out for professional suffix matches first
    if ($prof_match !== false) {
      return self::$dict['suffixes']['prof'][$prof_match];
    }
    # Now test our edge cases based on lineage
    if ($line_match !== false) {
      # Store our match
      $matched_case = self::$dict['suffixes']['line'][$line_match];
      # Remove it from the array
      $temp_array = self::$dict['suffixes']['line'];
      unset($temp_array[$line_match]);
      # Make sure we're dealing with the suffix and not a surname
      if ($word == 'senior' || $word == 'junior') {
        # If name is Joshua Senior, it's pretty likely that Senior is the surname
        # However, if the name is Joshua Jones Senior, then it's likely a suffix
        if (str_word_count($name) < 3) {
          return false;
        }
        # If the word Junior or Senior is contained, but so is some other
        # lineage suffix, then the word is likely a surname and not a suffix
        foreach ($temp_array as $suffix) {
          if (preg_match("/\b".$suffix."\b/i", $name)) {
            return false;
          }
        }
      }
      return $matched_case;
    }
    return false;
  }
protected static function is_suffix ( $ word , $ name ) { # Ignore periods, normalize case $ word = str_replace ( '.' , '' , strtolower ( $ word ) ) ; # Search the array for our word $ line_match = array_search ( $ word , array_map ( 'strtolower' , self :: $ dict [ 'suffixes' ] [ 'line' ] ) ) ; $ prof_match = array_search ( $ word , array_map ( 'strtolower' , self :: $ dict [ 'suffixes' ] [ 'prof' ] ) ) ; # Break out for professional suffix matches first if ( $ prof_match !== false ) { return self :: $ dict [ 'suffixes' ] [ 'prof' ] [ $ prof_match ] ; } # Now test our edge cases based on lineage if ( $ line_match !== false ) { # Store our match $ matched_case = self :: $ dict [ 'suffixes' ] [ 'line' ] [ $ line_match ] ; # Remove it from the array $ temp_array = self :: $ dict [ 'suffixes' ] [ 'line' ] ; unset ( $ temp_array [ $ line_match ] ) ; # Make sure we're dealing with the suffix and not a surname if ( $ word == 'senior' || $ word == 'junior' ) { # If name is Joshua Senior, it's pretty likely that Senior is the surname # However, if the name is Joshua Jones Senior, then it's likely a suffix if ( str_word_count ( $ name ) < 3 ) { return false ; } # If the word Junior or Senior is contained, but so is some other # lineage suffix, then the word is likely a surname and not a suffix foreach ( $ temp_array as $ suffix ) { if ( preg_match ( "/\b" . $ suffix . "\b/i" , $ name ) ) { return false ; } } } return $ matched_case ; } return false ; }
Checks word against array of common suffixes

@param string $word the single word you wish to test
@param string $name full name for context in determining edge-cases
@return mixed boolean if false, string if true (returns suffix)
Checks word against array of common suffixes