array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.chunk-split.php', 1 => 'chunk_split', ), 'up' => array ( 0 => 'ref.strings.php', 1 => '字符串 函数', ), 'prev' => array ( 0 => 'function.chr.php', 1 => 'chr', ), 'next' => array ( 0 => 'function.convert-cyr-string.php', 1 => 'convert_cyr_string', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/strings/functions/chunk-split.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
chunk_split — 将字符串分割成小块
使用此函数将字符串分割成小块非常有用。例如将
base64_encode() 的输出转换成符合 RFC 2045 语义的字符串。它会在每
length
个字符后边插入
separator
。
string
要分割的字符。
length
分割的尺寸。
separator
行尾序列符号。
返回分割后的字符。
示例 #1 chunk_split() 例子
<?php
// 使用 RFC 2045 语义格式化 $data
$new_string = chunk_split(base64_encode($data));
?>