格式化PHP生成的文本文件

I'm building a super simple PHP CMS, and have a question about formatting text...

I'm storing my news files in .txt files (should be SQL, I know), and would like to know how to format the text that gets saved in the text file. This is the code that stores the lines that I want to format:

$newsTitle = isset($_POST["title"]) ? $_POST["title"] : "Untitled";
$submitDate = date("m/d/y g:iA");

I want to wrap the first line in an <h2> and the second line in an <h3>, but I have no idea how. I tried just wrapping the m/d/y g:iA bit in the second line with a <h3> but that generated some really weird code in the .txt file.

Thanks!

$newsTitle = isset($_POST["title"]) ? $_POST["title"] : "Untitled";
$submitDate = date("m/d/y g:iA");
$saveString = "<h2>$newsTitle</h2>
<h3>$submitDate</h3>";
file_put_contents("filename.txt",$saveString);

Read up a little on php strings and how you can use variables with them. Good luck!

$newsTitle = isset($_POST["title"]) ? "<h2>".$_POST["title"]."</h2>" : "Untitled";
$submitDate = "<h3>".date("m/d/y g:iA")."</h3>";