Core Function ChunkSplit
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> ChunkSplit( <body>, <chunklen>, <end> ) </pre> === Description === Split a string into smaller chunks. === Parameters === ==== body ==== The string to be chunked. ==...") |
(→Example) |
||
Line 44: | Line 44: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
$string = '1234'; | $string = '1234'; | ||
− | say substr( | + | say substr(ChunkSplit($string, 2, ':'), 0, -1); |
// will return 12:34 instead of 12:34: | // will return 12:34 instead of 12:34: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 13:44, 11 September 2013
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: