Jump to content

Help with function and breakline output


EchoFool

Recommended Posts

I have a problem with my script. I input data using a function to maintain its line structure...

 

This part works fine...

$QuoteMessage = nl2br($row['Message']);
$UPDATE2 = mysql_query("INSERT INTO posts (ThreadID,UserID,Message,CreatedOn)
			VALUES ('$Thread','{$_SESSION['Current_User']}','$Post','$Date')")
				Or die(mysql_error());

 

How ever if i want to echo it with my function involved i get this:

 

Test<br /> test<br /> <br /> <br /> <br /> Test<br /> Test<br /> e<br /> <br /> tete<br /> w000

 

 

This is how it should look

Test<br /> test<br /> <br /> <br /> <br /> Test<br /> Test<br /> e<br /> <br /> tete<br /> w000

 

As you can see its not doing the lines but its echo'in the actual layout html code.

 

 

This is what i have for my output:

 

<?php
function BBCode($BB){
				$BBCode = array("&" => "&",
					"<" => "<",
					">" => ">",
					"[b]" => "<b>",
					"[/b]" => "</b>",
					"[i]" => "<i>",
					"[/i]" => "</i>",
					"[u]" => "<u>",
					"[/u]" => "</u>",
					"[Quote]" => "<div class='quotetop'>QUOTE</div><div class='quotemain'>",
					"[quote]" => "<div class='quotetop'>QUOTE</div><div class='quotemain'>",
					"[quote]" => "<div class='quotetop'>QUOTE</div><div class='quotemain'>",
					"[/Quote]" => "</div><br>",
					"[/quote]" => "</div><br>",
					"[/quote]" => "</div><br>",
					"[sQ]" =>  "<div class='quotetop'>QUOTE <span class=PositiveMoney> ",
					"[sQ2]" => "</span></div><div class='quotemain'>",
					"<br />" => "",);

				$Message = str_replace(array_keys($BBCode), array_values($BBCode), $BB);
			return $Message;
								}
//query get message stuff here

//------------------------

$newString = BBCode($Message);
			$newString = str_replace('<br />', '', $newString);
			echo $newString;?>

What did i do wrong?

Link to comment
https://forums.phpfreaks.com/topic/91963-help-with-function-and-breakline-output/
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.