SirChick Posted January 13, 2008 Share Posted January 13, 2008 I have a word wrap feature i just implement i literally copied and pasted yet it totally didnt work when i tested it lol... I got this: <td width="600" align=center><?$Message = wordwrap($Message, 600, "<br />\n"); ?><?=$Message?></td> It says on this site: http://us3.php.net/wordwrap width The column width. Defaults to 75. And as you see i have matched the width as 600 equally to the td width but i tested it and it pushed it way of my screen it didn't wrap to a new line at all. Even if i set the 600 to 60 it still wont wrap. Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted January 13, 2008 Share Posted January 13, 2008 Change wordwrap($Message, 600, to a much smaller number.. what the example was pretty much telling you is in your case you put 600, if a woooooooooooord is 600+ characters long it will break it down every 600 characters until the word is done until the next space.. try 12.. or 20.. and see how that works.. Quote Link to comment Share on other sites More sharing options...
KrisNz Posted January 13, 2008 Share Posted January 13, 2008 Does this work for you? <?php $message = <<<EOL This is a really really really long message that i want to wrap over several lines or something EOL; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>word wrap</title> </head> <body> <table> <tr> <td align="center" style="width:600px;border:1px solid red;"><?php echo wordwrap($message,10,"<br/>") ?></td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
SirChick Posted January 13, 2008 Author Share Posted January 13, 2008 <td width="600" align=center><?$Message = wordwrap($Message, 50, "<br />\n"); ?><?=$Message?></td> Still nothing observe print screen provided below! Kris ..a word wrap is to wrap a long word not a long sentence..i thought anyway? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
KrisNz Posted January 13, 2008 Share Posted January 13, 2008 ahhhh, you need to specify true for the "cut" parameter as in example 2 on the manual page then. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 13, 2008 Share Posted January 13, 2008 wordwrap() is for wrapping sentences at the nearest wordbreak (space) to fit the desired width. If you want it to split mid-word, set the final optional argument of wordwrap() to true (as Kris just said) Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted January 13, 2008 Share Posted January 13, 2008 <?php echo "<b>Message Orginal: (no tables)</b><br>"; $message = "what is gooooooooooooooooooooooooooing on dawg!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; echo $message . "<br><br>"; echo "<b>Message with Wrap (no tables):</b><br>"; $blah = wordwrap($message,10,"<br \>", true); echo "$blah<br \>"; ?> Sample @ http://www.monkeytooth.net/tests/messg.php Quote Link to comment Share on other sites More sharing options...
SirChick Posted January 13, 2008 Author Share Posted January 13, 2008 sorted thanks guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.