超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<chrconvert_cyr_string>
Last updated: Fri, 22 Jun 2007

chunk_split

(PHP 3>= 3.0.6, PHP 4 , PHP 5)

chunk_split -- 将字符串分割成小块

描述

string chunk_split ( string body [, int chunklen [, string end]])

使用此函数将字符串分割成小块非常有用。例如将 base64_encode 的输出转换成符合 RFC 2045 语义的字符串。它会在每 chunklen(默认为 76)个字符后边插入 end(默认为“\r\n”)。此函数会返回新的字符串,而不会修改原有字符串。

例子 1. chunk_split() 示例

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

参见 str_split()explode()split()wordwrap()RFC 2045




add a note add a note User Contributed Notes
chunk_split
sbarnum at pointsystems dot com
21-Apr-2001 10:46
[Editor's note: You can always use wordwrap('FF99FF', 2, ':', 2); to avoid this]

chunk_split will also add the break _after_ the last occurence.  So, attempting to split a color into base components,
chunk_split('FF99FF', 2, ':');
will return FF:99:FF:

<chrconvert_cyr_string>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22