Home Menu

chunk_split

Split a string into smaller chunks

Syntax

chunk_split ( string $body [, int $chunklen = 76 [, string $end = "\r\n" ]] ) : string

Parameters

body

The string to be chunked.

chunklen

The chunk length.

end

The line ending sequence.

Return

Returns the chunked string.

Examples

body

<?

$body = '12345';

$return = chunk_split($body);
echo $return;

?>
12345

chunklen

<?

$body = '12345';
$chunklen = 2;

$return = chunk_split($body, $chunklen);
echo $return;

?>
12
34
5

end

<?

$body = '12345';
$chunklen = 2;
$end = ',';

$return = chunk_split($body, $chunklen, $end);
echo $return;

?>
12,34,5,

base64_encode

<?

$data = 'encoded string';
$body = base64_encode($data);

$return = chunk_split($body);
echo $return;

?>
ZW5jb2RlZCBzdHJpbmc=

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms