chunk_split

(PHP 4, PHP 5, PHP 7, PHP 8)

chunk_split将字符串分割成小块

说明

chunk_split(string $string, int $length = 76, string $separator = "\r\n"): string

使用此函数将字符串分割成小块非常有用。例如将 base64_encode() 的输出转换成符合 RFC 2045 语义的字符串。它会在每 length 个字符后边插入 separator

参数

string

要分割的字符。

length

分割的尺寸。

separator

行尾序列符号。

返回值

返回分割后的字符。

范例

示例 #1 chunk_split() 例子

<?php
// 使用 RFC 2045 语义格式化 $data
$new_string = chunk_split(base64_encode($data));
?>

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top