[eluser]xwero[/eluser]
That splits the word but you get
THISPROGRA
MISATESTTO
SPLITTHELO
...
Which is a cryptic block of text to most of the people that just glance the page. That is why i'm not so found about splitting a string using character length based chunks. Because most long words use hypens or are urls, to make them readable you could use this
Code:
function split_long_word($word,$end='<br>')
{
$return = '';
if(preg_match('/^http/',$word)
{
$temp = substr($word,0,6); // removes http://
$domain = strstr($word, '/', true);
$return = '<a href="'.$word.'">'.$domain.'</a>';
}
else
{
$temp = explode('-',$word);
$return = '';
foreach($temp as $part){ $return .= $part.'-'.$end; }
}
return $return;
}
I think you let the exception become the rule.