I wanted to split a large text into 10 pieces (somehow equal parts). Ii use this function:
<?php
function chunk($msg) {
$msg = preg_replace('/[\r\n]+/', ' ', $msg);
//define character length of each text piece
$chunks = wordwrap($msg, 10000, '\n');
return explode('\n', $chunks);
}
$arrayys=chunk($t);
foreach($arrayys as $partt){echo $partt."<br/><br/><br/>";}
?>
But is it possible to define word length of each text piece (not character length )? how to divide text into words in such situation?