PHP chunk_split() Function Example

PHP Script:

<?php
echo chunk_split(“PHPTUTORS”,1,”_”);
echo “<br/ >”;
echo chunk_split(“Learn PHP on PHPTUTORS”,12,”…”);
?>

Output:

P_H_P_T_U_T_O_R_S_
Learn PHP on… PHPTUTORS…

Description:

chunk_split() function splits a string into a series of smaller chunks and append a specified string after each chunk as shown in above script example.

chunk_split function parameters:

1- String: String which is going to be spit into chunks
2- Chunk Length: Length of chunk [default is 76]
3- String: String which is appended at the end of each chunk

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s