<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 字符串輔助函數 字符串輔助函數文件包含了一些幫助你處理字符串的函數。 [TOC=2,3] ## [加載輔助函數](http://codeigniter.org.cn/user_guide/helpers/string_helper.html#id4) 該輔助函數通過下面的代碼加載: ~~~ $this->load->helper('string'); ~~~ ## [可用函數](http://codeigniter.org.cn/user_guide/helpers/string_helper.html#id5) 該輔助函數有下列可用函數: random_string([$type = 'alnum'[,?$len = 8]]) 參數: * **$type**?(string) -- Randomization type * **$len**?(int) -- Output string length 返回: A random string 返回類型: string 根據你所指定的類型和長度產生一個隨機字符串。可用于生成密碼或隨機字符串。 第一個參數指定字符串類型,第二個參數指定其長度。有下列幾種字符串類型可供選擇: * **alpha**: 只含有大小寫字母的字符串 * **alnum**: 含有大小寫字母以及數字的字符串 * **basic**: 根據?mt_rand()?函數生成的一個隨機數字 * **numeric**: 數字字符串 * **nozero**: 數字字符串(不含零) * **md5**: 根據?md5()?生成的一個加密的隨機數字(長度固定為 32) * **sha1**: 根據?sha1()?生成的一個加密的隨機數字(長度固定為 40) 使用示例: ~~~ echo random_string('alnum', 16); ~~~ 注解 unique?和?encrypt?類型已經廢棄,它們只是?md5?和?sha1?的別名。 increment_string($str[,?$separator = '_'[,?$first = 1]]) 參數: * **$str**?(string) -- Input string * **$separator**?(string) -- Separator to append a duplicate number with * **$first**?(int) -- Starting number 返回: An incremented string 返回類型: string 自增字符串是指向字符串尾部添加一個數字,或者對這個數字進行自增。 這在生成文件的拷貝時非常有用,或者向數據庫中某列(例如 title 或 slug)添加重復的內容, 但是這一列設置了唯一索引時。 使用示例: ~~~ echo increment_string('file', '_'); // "file_1" echo increment_string('file', '-', 2); // "file-2" echo increment_string('file_4'); // "file_5" ~~~ alternator($args) 參數: * **$args**?(mixed) -- A variable number of arguments 返回: Alternated string(s) 返回類型: mixed 當執行一個循環時,讓兩個或兩個以上的條目輪流使用。示例: ~~~ for ($i = 0; $i < 10; $i++) { echo alternator('string one', 'string two'); } ~~~ 你可以添加任意多個參數,每一次循環后下一個條目將成為返回值。 ~~~ for ($i = 0; $i < 10; $i++) { echo alternator('one', 'two', 'three', 'four', 'five'); } ~~~ 注解 如果要多次調用該函數,可以簡單的通過不帶參數重新初始化下。 repeater($data[,?$num = 1]) 參數: * **$data**?(string) -- Input * **$num**?(int) -- Number of times to repeat 返回: Repeated string 返回類型: string 重復生成你的數據。例如: ~~~ $string = "\n"; echo repeater($string, 30); ~~~ 上面的代碼會生成 30 個空行。 注解 該函數已經廢棄,使用原生的?str_repeat()?函數替代。 reduce_double_slashes($str) 參數: * **$str**?(string) -- Input string 返回: A string with normalized slashes 返回類型: string 將字符串中的雙斜線('//')轉換為單斜線('/'),但不轉換 URL 協議中的雙斜線(例如:[http://](http://codeigniter.org.cn/user_guide/helpers/string_helper.html)) 示例: ~~~ $string = "http://example.com//index.php"; echo reduce_double_slashes($string); // results in "http://example.com/index.php" ~~~ strip_slashes($data) 參數: * **$data**?(mixed) -- Input string or an array of strings 返回: String(s) with stripped slashes 返回類型: mixed 移除一個字符串數組中的所有斜線。 示例: ~~~ $str = array( 'question'??=> 'Is your name O\'reilly?', 'answer' => 'No, my name is O\'connor.' ); $str = strip_slashes($str); ~~~ 上面的代碼將返回下面的數組: ~~~ array( 'question'??=> "Is your name O'reilly?", 'answer' => "No, my name is O'connor." ); ~~~ 注解 由于歷史原因,該函數也接受一個字符串參數,這時該函數就相當于?stripslashes()?的別名。 trim_slashes($str) 參數: * **$str**?(string) -- Input string 返回: Slash-trimmed string 返回類型: string 移除字符串開頭和結尾的所有斜線。例如: ~~~ $string = "/this/that/theother/"; echo trim_slashes($string); // results in this/that/theother ~~~ 注解 該函數已廢棄,使用原生的?trim()?函數代替: | | trim($str, '/'); reduce_multiples($str[,?$character = ''[,?$trim = FALSE]]) 參數: * **$str**?(string) -- Text to search in * **$character**?(string) -- Character to reduce * **$trim**?(bool) -- Whether to also trim the specified character 返回: Reduced string 返回類型: string 移除字符串中重復出現的某個指定字符。例如: ~~~ $string = "Fred, Bill,, Joe, Jimmy"; $string = reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy" ~~~ 如果設置第三個參數為 TRUE ,該函數將移除出現在字符串首尾的指定字符。例如: ~~~ $string = ",Fred, Bill,, Joe, Jimmy,"; $string = reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy" ~~~ quotes_to_entities($str) 參數: * **$str**?(string) -- Input string 返回: String with quotes converted to HTML entities 返回類型: string 將字符串中的單引號和雙引號轉換為相應的 HTML 實體。例如: ~~~ $string = "Joe's \"dinner\""; $string = quotes_to_entities($string); //results in "Joe&#39;s &quot;dinner&quot;" ~~~ strip_quotes($str) 參數: * **$str**?(string) -- Input string 返回: String with quotes stripped 返回類型: string 移除字符串中出現的單引號和雙引號。例如: ~~~ $string = "Joe's \"dinner\""; $string = strip_quotes($string); //results in "Joes dinner" ~~~
                  <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>

                              哎呀哎呀视频在线观看