Supreme Council
Joined: 2006/11/16 19:25 Last Login
: Yesterday 20:44
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
|
@xeron
I know, I have code that wraps text in 80 columns with some intelligence in it that doesn't work the way I want it to. I got it from nicomen, but unfortunately I've never bothered to learn what preg_replace does to be able to fix it.
function smartWrap($text,$width,$break="\n",$cut=1) { $text = str_replace("$", "$", $text);
if (preg_match("/[^\n]{".$width."}/",$text)) { $text = preg_replace("/\\\\('|\")/msi","$1",preg_replace("/(.*?)(\n\n|\.\n|:\n|=+\n|\s*-{3,}\s*\n)/msie",'(preg_match("/[^\n]{$width}/mi","$1")) ? preg_replace("/(\S+)[\t ]?\n/","\$1 ","$1")."$2" : "$1$2"',$text)); $text = str_replace(""$"","$",$text); return wordwrap($text,$width,$break,$cut); } else { return $text; } }
|