<?=$postcontent = wordwrap($qry_post['content'], 67, "<br />", true);?>如果内容中有一个很长的链接,或者有一个大代码,它会在某个部分停止它,然后
它将产生一个html实体,因为新的行/
在src代码中。
有什么办法解决这个问题吗?谢谢!
发布于 2013-03-13 06:18:59
在manual for wordwrap()的评论中,有人发布了一个代码片段来解决这个问题:
<?php
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;
}
?>https://stackoverflow.com/questions/15373276
复制相似问题