Hey guys, so right now I'm inputting in text from a text area using this:
$string = "Text with line breaks from a form";
$string = nl2br_limit($string, 3);
// Here is the function used so users can't put in crazy number of linebreaks
function nl2br_limit($string, $num){
$dirty = preg_replace('/\r/', '', $string);
$clean = preg_replace('/\n{4,}/', str_repeat('<br/>', $num), preg_replace('/\r/', '', $dirty));
return nl2br($clean);
}
$string = check_input($string);
// Here is my check_input code to prevent sql injections and such.
function check_input($value)
{
$value = mysql_real_escape_string($value);
return $value;
}
So then $string is inserted into the database.
However, when I call it back (so user's can edit what the originally put in), I get code that outputs <br>
Example:
This is code <br>
That outputs the <br>.
How do you go about so that you get rid of the <br>'s and essentially input in the same code/formatting that you retreived?
When I insert the code back in without the <br> but with linebreaks, the line breaks don't register and it's all on one line.
Thanks in advance everyone.