chunk_split_PHP chunk_split()函数与示例
chunk_split
PHP chunk_split()函數(shù) (PHP chunk_split() function)
chunk_split() function is used to split the given string into chunks of small parts, it accepts the string returns the parts of the strings specified by the other parameters.
chunk_split()函數(shù)用于將給定的字符串分割成小塊,它接受該字符串返回其他參數(shù)指定的字符串部分。
Syntax:
句法:
chunk_split(string, [chunklen], [end_characters]);Here,
這里,
string - is the source string
string-是源字符串
chunklen - is an optional parameter, it defines the number of characters of the chunks. It's default value is 75.
chunklen-是一個(gè)可選參數(shù),它定義塊的字符數(shù)。 默認(rèn)值為75。
end_characters - is also an optional parameter, it defines the end characters that will be added to the each chunk, and its default value is "\r\n".
end_characters-也是一個(gè)可選參數(shù),它定義了將添加到每個(gè)塊中的結(jié)束字符,其默認(rèn)值為“ \ r \ n” 。
Examples:
例子:
Input: str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"Function call: chunk_split(str, 3, "...");Output:ABCD...EFGH...IJKL...MNOP...QRST...UVWX...YZ...PHP code:
PHP代碼:
<?php$str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";$split_str = chunk_split($str);echo ("The extracted characters are...\n");echo ($split_str);$split_str = chunk_split($str, 3);echo ("The extracted characters are...\n");echo ($split_str);$split_str = chunk_split($str, 4, "...");echo ("The extracted characters are...\n");echo ($split_str); ?>Output
輸出量
The extracted characters are... ABCDEFGHIJKLMNOPQRSTUVWXYZ The extracted characters are... ABC DEF GHI JKL MNO PQR STU VWX YZ The extracted characters are... ABCD...EFGH...IJKL...MNOP...QRST...UVWX...YZ...翻譯自: https://www.includehelp.com/php/chunk_split-function-with-example.aspx
chunk_split
總結(jié)
以上是生活随笔為你收集整理的chunk_split_PHP chunk_split()函数与示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python无符号转有符号_Python
- 下一篇: Java ArrayList conta