本文整理汇总了PHP中CString::mergeWhiteSpace方法的典型用法代码示例。如果您正苦于以下问题:PHP CString::mergeWhiteSpace方法的具体用法?PHP CString::mergeWhiteSpace怎么用?PHP CString::mergeWhiteSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::mergeWhiteSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sterilizeTextField
function sterilizeTextField($s)
{
$str = new CString();
$s = htmlspecialchars(str_replace(";", "", $str->mergeWhiteSpace($str->stripHTML($s))));
return $s;
}
示例2: getIndexWordsFromText
function getIndexWordsFromText($text, $max_text_len_to_scan = 1024, $min_len_index_word = 1, $max_len_index_word = 50)
{
loadCoreFile('cstring.php');
$cstring = new CString();
$text = _ml_substr($text, 0, $max_text_len_to_scan);
$text = $cstring->stripHTML($text);
// strip punctuation
$chars = array("\$", ".", "!", "?", "@", ",", "#", "%", "^", "&", "*", "(", ")", "_", "+", "=", "(", ")", "{", "}", "[", "]", "\\", "|", ";", ":", "\"", "<", ">", "/", "~", "-", "'");
$search = array();
$replace = array();
$search[] = "/([" . implode("\\", $chars) . "]+)/";
$replace[] = " ";
$text = preg_replace($search, $replace, $text);
$text = $cstring->mergeWhiteSpace($text);
$words = explode(" ", $text);
// one more, remove wrong-length words
foreach ($words as $key => $word) {
if (0 == _ml_strlen($word) || _ml_strlen($word) < $min_len_index_word || _ml_strlen($word) > $max_len_index_word) {
unset($words[$key]);
}
}
return $words;
}