Jump to content

Move Content Left (remove space on right)


BandonRandon

Recommended Posts

Hello, I'm trying to create a simple content formater. I would like to be able to paste content from and e-mail and have it format it in an easy printer friendly way. Right now I have the following php code:

$text= $_POST['textinput'];

	$paragraphs= $_POST['keep_paragraphs'];
	$shift_left= $_POST['shift_left'];
	if(get_magic_quotes_gpc()){
	$text = stripslashes($text);
	// strip off the slashes if they are magically added.
	}
	$text = htmlentities($text);
	//if we should keep formatting
	if($paragraphs=="true"){
		$text =nl2br($text);
	}
	//if we want to shift all text left if no break is inbetween
	if($shift_left=="true"){
		$text = preg_replace('/(?<!\r\n)\r\n(?=\w)/', ' ', trim($text));

	}
echo ($text);

 

The part that isn't working is the preg_replace. I am trying to make it so

This

Is

The First

Paragraph

 

Second Paragraph

 

Becomes

This Is The First Paragraph

 

Second Paragraph

 

Any Ideas would be great.

Link to comment
Share on other sites

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.