PHP chunk_split() Function
You are Here:
PHP chunk_split()
The chunk_split()
function splits a string into smaller chunks.
Note: This function does not alter the original string.
Example
PHP Compiler
<?php
$str = "PHP World";
echo chunk_split($str, 1, ".");
?>
Output
P.H.P. .W.o.r.l.d.
Syntax
chunk_split(str, chunklen, end)
Parameter Values
Value | Type | Explanation |
---|---|---|
str | Required | Specifies the string to split. |
chunklen | Optional | Specifies the chunk length. |
end | Optional | Specifies the end of each chunk. Default value is \r\n. |
Return Value
Value | Explanation |
---|---|
Number | Returns the chunked string. |
More Examples
Example
PHP Compiler
<?php
$str = "PHP World";
echo chunk_split($str, 2, "..");
?>
Output
PH..P ..Wo..rl..d..
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on PHP with examples for quick and easy learning.
We are working to cover every Single Concept in PHP.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.