Wes1890 Posted November 3, 2005 Share Posted November 3, 2005 I've got a CMS system on my site... and last nite before I went to bed, i posted myself a reminder to do something bla bla bla... well, posted something like this: Well i'm off to bed... it's 3:20am! This is also a reminder to FIX THE MEMCP FILE!! well, the problem is, it shows up like this: Well i'm off to bed... it's 3:20am! This is also a reminder to FIX THE MEMCP FILE!! It removes the "newlines" and the multiple spaces.... how would i have it keep them? Big thanks Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted November 3, 2005 Share Posted November 3, 2005 browsers ignore spaces and newlines. they're in the source but they're not displayed. surround the text with <pre> </pre>, or use and <br> Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 3, 2005 Author Share Posted November 3, 2005 The original message is this: bla bla bla bla bla poo The <pre> idea works, but disables the word wrap that the browser has default... Using <b>strtr()</b> i replaced all spaces with <b> </b> and replaces all lines with <br />... but the message came out something like this: bla&bla&bla&bla&bla So, for the lines i put $message_line = strtr($message,""," "); Which made bla bla bla bla bla poo (poo only went down 1 line.. instead of the original 2) Thanks for the reply... but any more ideas? Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted November 3, 2005 Share Posted November 3, 2005 you should use str_replace instead of strtr. and use nl2br to convert newlines to br $message_line=str_replace(' ',' ',nl2br($message)); Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 3, 2005 Author Share Posted November 3, 2005 I knew there was a string replace function.... but i used strreplace by mistake... thanks a bunch.. But now there is another problem (figures...) The text inside the tables do not wrap, even when i shrink the width of the tables. Is there a way to wrap text? Or is there a way to count an amount of characters (length) and have it make a new line after there are so many letters? (without cutting words in half) ^Big thanks to you man.. but what about word wrapping? Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted November 3, 2005 Share Posted November 3, 2005 the answer lies in what you wanna do: wordwrap() Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 4, 2005 Author Share Posted November 4, 2005 It isn't working for some reason... ??? This is the code ($message is what needs wrapped... also, language filter is my own function, just ignore it) // Display the news while($r=mysql_fetch_array($getnews)) { extract($r); // Put DB info as VARS $title = stripslashes($title); // Strip slashes $message = stripslashes($message); // Strip slashes $message_line = str_replace(' ',' ',nl2br($message)); // Make new lines $message_clean = language_filter($message_line); // Filter the language $message_wrap = wordwrap($message_clean, 20, "<br />\n"); // Wrap the message $final_message = $message_wrap; // The final piece echo "Message: {$final_message}"; // Show the message } Why wont it work? Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 4, 2005 Author Share Posted November 4, 2005 *bump* Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 5, 2005 Author Share Posted November 5, 2005 Ohh.. i fixed it.. I had to have the nl2br function AFTER the wrap command... Thanks ryan 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.