Split string after every five words
php, preg-split
Solution
You can use a regular expression too
$str = 'There is something to type here. This is an example text';
echo preg_replace( '~((?:\S*?\s){5})~', "$1\n", $str );
There is something to type here. This is an example text
Problem
I want to split a string after every five words. Example There is something to type here. This is an example text Output ``` There is something to type here. This is an example text ``` How can this be done using `preg_split()`? Or is there any way to wrap text in PHP GD?