I\'m trying to split strings in half, and it should not split in the middle of a word.
So far I came up with the following which is 99% working :
$te
function split_half($string, $center = 0.4) {
$length2 = strlen($string) * $center;
$tmp = explode(' ', $string);
$index = 0;
$result = Array('', '');
foreach($tmp as $word) {
if(!$index && strlen($result[0]) > $length2) $index++;
$result[$index] .= $word.' ';
}
return $result;
}
Demo: http://codepad.viper-7.com/I58gcI