# Replacing "\\n" with "\<br /\>"

**URL:** https://forum.kirupa.com/t/replacing-n-with-br/166002
**Category:** Uncategorized
**Created:** [October 16, 2005, 1:46am UTC](https://forum.kirupa.com/t/replacing-n-with-br/166002 "2005-10-16T01:46:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![eyeofthestorm](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@eyeofthestorm](https://forum.kirupa.com/u/eyeofthestorm)
#### Post date: [October 16, 2005, 1:46am UTC](https://forum.kirupa.com/t/replacing-n-with-br/166002/1 "2005-10-16T01:46:10Z")

</div>

i have a form that i want to to change all "  
"'s in the form to “\<br /\>”'s and then store them to a single line on a text file…but when i do this, when they write to the text file, it doesn’t store it on a single line, but on a different line for each "  
"…can anyone help me? here is my code:

```php
$title = htmlspecialchars($_POST['title']);
$title = str_replace("|", "|", $title);
$content = htmlspecialchars($_POST['content']);
$content = stripslashes($content);
$content = preg_replace("'
'", "<br />", $content);
$content = str_replace("|", "|", $content);
$day = date("d-n-y");
$time = date("g:ia");
	$news_item = array($day, $time, $title, $content);
$toWrite = implode("|", $news_item);
$filename = "data/news.txt";
if (is_writable($filename)) {
	if (!$handle = fopen($filename, 'a')) {
		echo "Cannot open file ($filename)";
		exit;
	}
	if (fwrite($handle, $toWrite) === FALSE) {
		echo "Cannot write to file ($filename)";
		exit;
	}
 
print "<center><b><font color=\"#009933\">Successfully added news post to database</font></b><br></center>";
	fclose($handle);
	} else {
		echo "The file $filename is not writable";
	}
print "<center><a href=\"news.php?mod=nadd\">add another news post</a></center>";

```

this stores this:  
15-10-05|6:36pm|title|content  
\<br /\>newline  
\<br /\>newline

when i want it to store this:  
15-10-05|6:36pm|title|content\<br /\>newline\<br /\>newline
