Jump to content

Recommended Posts

I am doing a message board.

 

I am using html entities to stop people using tags etc.

 

However if I typed exactly what I have typed here in my message board, I would get:

 

"

I am doing a message board.

I am using html entities to stop people using tags etc.

However if I typed exactly what I have typed here in my message board, I would get:

"

 

I still want people to be able to press enter etc. - what do I do?

I have line breaks added via bbcode so if the bbcode file is missing the line you wrote wouldnt have line breaks it be all joined together. If your thinking of using bbcode for smiles then maybe you could try that this allows line breaks as i use it on a news script.

great, thanks.

 

The Little Guy's solution is perfect.

 

Just another thought. What if people tried to press enter many times. Would I be able to stop this?

 

Ie PHP to pick up more than 4 line breaks and convert it all into 2 etc.

 

Test: see how PHP Freaks deals with this:

 

Hello

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello

Test: see how PHP Freaks deals with this:

 

Hello

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello

 

You'll have to use regex to convert multiple new lines in to a single newline, eg

 

$str = "Hello





Hello


World";

$str = preg_replace('|(\s){3,}|s', "\n", $str);

echo nl2br($str);

Sorry, one more.

 

Wildteen88 has a good solution, but this would convert:

 

Hello

 

How are you?

 

 

 

 

 

From Jim

 

into:

 

Hello

How are you?

From Jim

 

 

Ideally it would do:

 

Hello

 

How are you?

 

From Jim

 

 

In other words, it allows 2 line breaks, but converts 20 (for example) into 2 (not 1)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.