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
https://forums.phpfreaks.com/topic/230498-move-content-left-remove-space-on-right/
Share on other sites

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.