wordwrap only on long words help needed
Posted on 2009-02-10
I'm having some trouble with this, a couple of solutions have worked in testing, but in practice in the script not been quite right, but I am learning and narrowing it down :)
I need to use the php wordwrap function, but not on the entire string (which is a post/comment in a forum). Occasionally someone will put a long url in the post and it messes up the page layout. I want to break up just that long word/url, while letting the rest of the text flow naturally.
What I think I need here, is something like this:
now some kind of for or while statement that says for any $string_array piece over 70 characters, do this:
$cuttext = wordwrap($longtext, 70, "<br>", true);
then implode it back together with the cuttext back in place?.
I have no idea how to actually write that though. Thanks for any help, Chris