To by som rád fixol aj ja, problém je v tom, že k tomu treba dobrú znalosť regulárnych výrazov, ktorú nemám, takže jedine manuál. Zdá sa mi, že niečo také som tam videl k funkci wordwrap:
function textWrap($text) {
$new_text = '';
$text_1 = explode('>',$text);
$sizeof = sizeof($text_1);
for ($i=0; $i<$sizeof; ++$i) {
$text_2 = explode('<',$text_1[$i]);
if (!empty($text_2[0])) {
$new_text .= preg_replace('#([^\n\r .]{25})#i', '\\1 ', $text_2[0]);
}
if (!empty($text_2[1])) {
$new_text .= '<' . $text_2[1] . '>';
}
}
return $new_text;
}
alebo:
<?PHP
function mywordwrap($str, $max = 75, $break = ' ') {
// create array by deviding at each occurrence of "<a"
$arr = explode('<a', $str);
// break up long words in $arr[0] since
// it will never contain a hyberlink
$arr[0] = preg_replace('/([^\s]{'.$max.'})/i',"$1$break",$arr[0]);
// run loop to devide remaining elements
for($i = 1; $i < count($arr); $i++) {
// devide each element in $arr at each occurrence of "</a>"
$arr2 = explode('</a>', $arr[$i]);
// break up long words in $arr2 that does not
// contain hyberlinks
$arr2[1] = preg_replace('/([^\s]{'.$max.'})/i',"$1$break",$arr2[1]);
// rejoin $arr2 and assign as element in $arr
$arr[$i] = join('</a>', $arr2);
}
// rejoin $arr to string and return it
return join('<a', $arr);
}
?>