Example #1
0
 /**
  * Returns true if the every character in the parameter is an alphabetic
  * character.
  *
  * @param $string   The string to test.
  * @param $charset  The charset to use when testing the string.
  *
  * @return boolean  True if the parameter was alphabetic only.
  */
 public function isAlpha($string, $charset = null)
 {
     if (!Horde_String::extensionExists('mbstring')) {
         return ctype_alpha($string);
     }
     $charset = Horde_String::_mbstringCharset($charset);
     $old_charset = mb_regex_encoding();
     $old_error = error_reporting(0);
     if ($charset != $old_charset) {
         mb_regex_encoding($charset);
     }
     $alpha = !mb_ereg_match('[^[:alpha:]]', $string);
     if ($charset != $old_charset) {
         mb_regex_encoding($old_charset);
     }
     error_reporting($old_error);
     return $alpha;
 }