Trying to replace new lines from what the user enters in a textarea into the html code '<br/>'
Of course nl2br() was created for this very reason. Somehow its not working though.
PHP Code:
$title = $_POST['pgtitle']; $heading = $_POST['heading']; $content = $_POST['content']; $content = nl2br($content); $ecm2 = preg_replace ('/\[title\](.*?)\[\/title\]/is', '</p><h1>$1</h1><p>', $ecm2); $ecm2 = preg_replace ('/\[b\](.*?)\[\/b\]/is', '<strong>$1</strong>', $ecm2); $ecm2 = preg_replace ('/\[i\](.*?)\[\/i\]/is', '<em>$1</em>', $ecm2); $ecm2 = preg_replace ('/\[u\](.*?)\[\/u\]/is', '<u>$1</u>', $ecm2); $ecm2 = preg_replace ('/\[img\](.*?)\[\/img\]/is', '<img src="$1" alt="Image" />', $ecm2); $ecm2 = preg_replace ('/\[url=(.*?)\](.*?)\[\/url\]/i', '<a href="$1">$2</a>', $ecm2); $ecm2 = htmlentities($ecm2);
$form = $ecm2;
echo '<form action="download.php" method="post"><textarea name="textarea" cols="80" rows="20">'.$form.' </textarea><input type="hidden" name="filename" value="'.$title.'"> <br><input type="submit" value="Download"></form>';
Some more info:
$form = $ecm2
$ecm2 is in a separate file which has been included on the top line of my whole php page.
$content
$content is part of $ecm2.
PHP Warnings
No warnings received from this script.
preg_replace
Is fully working
|