<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 文本輔助函數 文本輔助函數文件包含了一些幫助你處理文本的函數。 [TOC=2,3] ## [加載輔助函數](http://codeigniter.org.cn/user_guide/helpers/text_helper.html#id4) 該輔助函數通過下面的代碼加載: ~~~ $this->load->helper('text'); ~~~ ## [可用函數](http://codeigniter.org.cn/user_guide/helpers/text_helper.html#id5) 該輔助函數有下列可用函數: word_limiter($str[,?$limit = 100[,?$end_char = '&#8230;']]) 參數: * **$str**?(string) -- Input string * **$limit**?(int) -- Limit * **$end_char**?(string) -- End character (usually an ellipsis) 返回: Word-limited string 返回類型: string 根據指定的?單詞?個數裁剪字符串。例如: ~~~ $string = "Here is a nice text string consisting of eleven words."; $string = word_limiter($string, 4); // Returns: Here is a nice ~~~ 第三個參數用于給裁剪的字符串設置一個可選的后綴,默認使用省略號。 character_limiter($str[,?$n = 500[,?$end_char = '&#8230;']]) 參數: * **$str**?(string) -- Input string * **$n**?(int) -- Number of characters * **$end_char**?(string) -- End character (usually an ellipsis) 返回: Character-limited string 返回類型: string 根據指定的?字符?個數裁剪字符串。它會保證單詞的完整性,所以最終生成的 字符串長度和你指定的長度有可能會有出入。 例如: ~~~ $string = "Here is a nice text string consisting of eleven words."; $string = character_limiter($string, 20); // Returns: Here is a nice text string ~~~ 第三個參數用于給裁剪的字符串設置一個可選的后綴,如果沒該參數,默認使用省略號。 注解 如果你需要將字符串精確的裁剪到指定長度,請參見下面的?[ellipsize()](http://codeigniter.org.cn/user_guide/helpers/text_helper.html#ellipsize "ellipsize")?函數。 ascii_to_entities($str) 參數: * **$str**?(string) -- Input string 返回: A string with ASCII values converted to entities 返回類型: string 將 ASCII 字符轉換為字符實體,包括高位 ASCII 和 Microsoft Word 中的特殊字符, 在 Web 頁面中使用這些字符可能會導致問題。轉換為字符實體后,它們就可以 不受瀏覽器設置的影響正確的顯示出來,也能可靠的存儲到到數據庫中。本函數依賴于 你的服務器支持的字符集,所以它可能并不能保證 100% 可靠,但在大多數情況下, 它都能正確的識別這些特殊字符(例如重音字符)。 例如: ~~~ $string = ascii_to_entities($string); ~~~ convert_accented_characters($str) 參數: * **$str**?(string) -- Input string 返回: A string with accented characters converted 返回類型: string 將高位 ASCII 字符轉換為與之相等的普通 ASCII 字符,當你的 URL 中需要使用 非英語字符,而你的 URL 又設置了只允許出現普通 ASCII 字符時很有用。 例如: ~~~ $string = convert_accented_characters($string); ~~~ 注解 該函數使用了?application/config/foreign_chars.php?配置文件來決定 將什么字符轉換為什么字符。 word_censor($str,?$censored[,?$replacement = '']) 參數: * **$str**?(string) -- Input string * **$censored**?(array) -- List of bad words to censor * **$replacement**?(string) -- What to replace bad words with 返回: Censored string 返回類型: string 對字符串中出現的敏感詞進行審查。第一個參數為原始字符串,第二個參數 為一個數組,包含你要禁用的單詞,第三個參數(可選)可以設置將出現 的敏感詞替換成什么,如果未設置,默認替換為磅字符:#### 。 例如: ~~~ $disallowed = array('darn', 'shucks', 'golly', 'phooey'); $string = word_censor($string, $disallowed, 'Beep!'); ~~~ highlight_code($str) 參數: * **$str**?(string) -- Input string 返回: String with code highlighted via HTML 返回類型: string 對一段代碼(PHP、HTML 等)進行著色。例如: ~~~ $string = highlight_code($string); ~~~ 該函數使用了 PHP 的?highlight_string()?函數,所以著色的顏色是在 php.ini 文件中設置的。 highlight_phrase($str,?$phrase[,?$tag_open = ''[,?$tag_close = '']]) 參數: * **$str**?(string) -- Input string * **$phrase**?(string) -- Phrase to highlight * **$tag_open**?(string) -- Opening tag used for the highlight * **$tag_close**?(string) -- Closing tag for the highlight 返回: String with a phrase highlighted via HTML 返回類型: string 對字符串內的一個短語進行突出顯示。第一個參數是原始字符串, 第二個參數是你想要突出顯示的短語。如果要用 HTML 標簽對短語進行標記, 那么第三個和第四個參數分別是你想要對短語使用的 HTML 開始和結束標簽。 例如: ~~~ $string = "Here is a nice text string about nothing in particular."; echo highlight_phrase($string, "nice text", '<span style="color:#990000;">', '</span>'); ~~~ 上面的代碼將輸出: ~~~ Here is a <span style="color:#990000;">nice text</span> string about nothing in particular. ~~~ 注解 該函數默認是使用??標簽,老版本的瀏覽器可能不支持??這個 HTML5 新標簽,所以如果你想支持這些老的瀏覽器,推薦你在你的樣式文件 中添加如下 CSS 代碼: ~~~ mark { background: #ff0; color: #000; }; ~~~ word_wrap($str[,?$charlim = 76]) 參數: * **$str**?(string) -- Input string * **$charlim**?(int) -- Character limit 返回: Word-wrapped string 返回類型: string 根據指定的?字符?數目對文本進行換行操作,并且保持單詞的完整性。 例如: ~~~ $string = "Here is a simple string of text that will help us demonstrate this function."; echo word_wrap($string, 25); // Would produce: // Here is a simple string // of text that will help us // demonstrate this // function. ~~~ ellipsize($str,?$max_length[,?$position = 1[,?$ellipsis = '&hellip;']]) 參數: * **$str**?(string) -- Input string * **$max_length**?(int) -- String length limit * **$position**?(mixed) -- Position to split at (int or float) * **$ellipsis**?(string) -- What to use as the ellipsis character 返回: Ellipsized string 返回類型: string 該函數移除字符串中出現的標簽,并根據指定的長度裁剪字符串,并插入省略號。 第一個參數是要處理的字符串,第二個參數為最終處理完后的字符串長度, 第三個參數為插入省略號的位置,值為 0-1 表示從左到右。例如設置為 1 省略號將插入到字符串的右側,0.5 將插入到中間,0 將插入到左側。 第四個參數是可選的,表示省略號的類型,默認是 &hellip; 。 例如: ~~~ $str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg'; echo ellipsize($str, 32, .5); ~~~ 輸出結果: ~~~ this_string_is_e&hellip;ak_my_design.jpg ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看