Chunk Split

Chunk Split is the good example for handling string for advanced customization. The below example will show you the customizing the string by spliting the paragraph by 20 lines each and the next example inserting the dot(.) in each character of the string,

Example 1:

$bild = “Angus Lewis Macdonald (1890–1954) was a Nova Scotian lawyer, law professor and politician. He served as the Liberal premier of Nova Scotia from 1933 to 1940 when he became the federal minister of defence for naval services. He oversaw the creation of an effective Canadian navy and Allied convoy service during World War II. After the war, he returned to Nova Scotia to become premier again. In the election of 1945, his Liberals swept back into power while their main rivals, the Conservatives, failed to win a single seat. The Liberal rallying cry, All’s Well With Angus L. seemed so convincing that the Conservatives despaired of ever beating Macdonald. He died suddenly in office in 1954. Macdonald’s more than 15 years as premier brought fundamental changes. Under his leadership, the Nova Scotian government spent more than $100 million paving roads, building bridges, extending electrical systems and improving public education. Macdonald dealt with the mass unemployment of the Great Depression by putting the jobless to work on highway projects. Macdonald was one of the most eloquent political orators in Nova Scotian history.”;

$emailbody = chunk_split($bild,50,'<br/>’);
echo $emailbody;

Example 2:   

$str = “Hello world!”;
echo chunk_split($str,1,”.”);
 

 

Output:
                     H.e.l.l.o. w.o.r.l.d

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: