Jump to content

How do i not remove the spaces?


Wes1890

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/2792-how-do-i-not-remove-the-spaces/
Share on other sites

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?

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?

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.