matak
07-05-2007, 09:42 PM
Hy
My write to file textarea form needs a bit processing before it's saved to file. Dunno really if there is better or faster way to create this but here's the problem.
I'm processing text in textarea with simple pregreplace so that on Return (/n) it adds </p><p>
Here's the code in steps
$tekstmanage = preg_replace('/\n/',"</p>\n<p>",
strip_tags($_POST['content']));
$content = "<p>".$tekstmanage."</p>";
My form adds closing and starting tag wherever there is /n. But if user hits few return keys then i end up with few empty <p></p> tags.
I wanted to remove them with this code
$tekstmanage2 = preg_replace ('/</p>\n<\/p>/', '', $tekstmanage);
But i got this error
Warning: preg_replace() [function.preg-replace]: Unknown modifier 'p' in ...\htdocs\PHP\Form_To_File\form.php on line 6
Any ideas how to remove those extra p tags? Or a better way to do the same.
Thanks in advance
My write to file textarea form needs a bit processing before it's saved to file. Dunno really if there is better or faster way to create this but here's the problem.
I'm processing text in textarea with simple pregreplace so that on Return (/n) it adds </p><p>
Here's the code in steps
$tekstmanage = preg_replace('/\n/',"</p>\n<p>",
strip_tags($_POST['content']));
$content = "<p>".$tekstmanage."</p>";
My form adds closing and starting tag wherever there is /n. But if user hits few return keys then i end up with few empty <p></p> tags.
I wanted to remove them with this code
$tekstmanage2 = preg_replace ('/</p>\n<\/p>/', '', $tekstmanage);
But i got this error
Warning: preg_replace() [function.preg-replace]: Unknown modifier 'p' in ...\htdocs\PHP\Form_To_File\form.php on line 6
Any ideas how to remove those extra p tags? Or a better way to do the same.
Thanks in advance