Core Function ChunkSplit

From Sputnik Wiki
Jump to: navigation, search
ChunkSplit( <body>, <chunklen>, <end> )

Contents

Description

Split a string into smaller chunks.

Parameters

body

The string to be chunked.

chunklen

The chunk length.

end

The line ending sequence.

Return Value

Success: Returns the chunked string.

Failure: Returns null.

Remarks

None

Example

$string = '1234'; 
say ChunkSplit($string, 2, ':'); // Prints 12:34:
 
$string = '123'; 
say ChunkSplit($string, 2, ':'); // Prints 12:3

The best way to solve the problem (if its a problem for you) with the last string added by ChunkSplit() is:

$string = '1234';
say substr(ChunkSplit($string, 2, ':'), 0, -1);
// will return 12:34 instead of 12:34:
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox