當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CString::stripHTML方法代碼示例

本文整理匯總了PHP中CString::stripHTML方法的典型用法代碼示例。如果您正苦於以下問題:PHP CString::stripHTML方法的具體用法?PHP CString::stripHTML怎麽用?PHP CString::stripHTML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CString的用法示例。


在下文中一共展示了CString::stripHTML方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sterilizeTextField

 function sterilizeTextField($s)
 {
     $str = new CString();
     $s = htmlspecialchars(str_replace(";", "", $str->mergeWhiteSpace($str->stripHTML($s))));
     return $s;
 }
開發者ID:KICHIRO20,項目名稱:-Myproject_part1-,代碼行數:6,代碼來源:data_writer_products_froogle.php

示例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;
}
開發者ID:KICHIRO20,項目名稱:-Myproject_part1-,代碼行數:23,代碼來源:functions.php


注:本文中的CString::stripHTML方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。