In am not sure what are you going to do, because you haven't told us your code. I think this will help you:
<?php
$file = 'demo.txt';
$content = "Example\n";
file_put_contents($file, $content);
?>
The file is demo.txt
(it is at the same location with the PHP document.
$content
is the text which will be put on your txt file.
Hope it helps!