PHP: chunk_split() function
PHP: Split a string into smaller chunks
The chunk_split() function is used to split a string into a series of smaller chunks.
Version:
(PHP 4 and above)
Syntax:
chunk_split(string_name, string_length, end_string)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
string_name | The string to be split. | Required | String |
string_length | The chunk length. | Optional | Integer |
end_string | The line ending sequence. | Optional | String |
Return values
The extracted string.
Value Type: String.
Pictorial Presentation
Example:
<?php
$string_name1='w3resource.com';
echo chunk_split($string_name1,1,".");
echo '<br>';
echo chunk_split($string_name1,2,"/");
echo '<br>';
echo chunk_split($string_name1,1,"--");
?>
Output:
w.3.r.e.s.o.u.r.c.e...c.o.m. w3/re/so/ur/ce/.c/om/ w--3--r--e--s--o--u--r--c--e--.--c--o--m--
View the example in the browser
See also
Previous: chr
Next: convert_cyr_string
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/php/function-reference/chunk_split.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics