note 81610 deleted from function.fwrite by tularis
| From: | tularis@php.net | Date: | Thu, 06 Mar 2008 16:39:16 +0000 |
| Subject: | note 81610 deleted from function.fwrite by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-136796@lists.php.net to get a copy of this message | ||
Note Submitter: jnkrois at gmail dot com
----
The following code allows me to write into an existing html file.
<?php
$my_file = "my_file.php";
$fh = fopen($my_file, 'a') or die("can't open file");
$string_data = "any_random_text";
fwrite($fh, $string_data);
echo "File succesfully written";
?>
The problem with this script is that it would write the "$string_data" (any_random_text)
at the end of the html file, after the </html> closing tag.
I hope someone can give me some advice to modify the code so it locates a specific tag in the html
file and add the "$string_data" to it; like so:
<body>
<div id="my_div">
any_given_text
</div>
</body>
...
Thanks