note 81610 added to function.fwrite

From: Date: Thu, 06 Mar 2008 06:48:49 +0000
Subject: note 81610 added to function.fwrite
Groups: php.notes 
Request: Send a blank email to php-notes+get-136780@lists.php.net to get a copy of this message
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 ---- Server IP: 64.71.164.2 Probable Submitter: 66.229.137.55 ---- Manual Page -- http://www.php.net/manual/en/function.fwrite.php Edit -- https://master.php.net/note/edit/81610 Del: integrated -- https://master.php.net/note/delete/81610/integrated Del: useless -- https://master.php.net/note/delete/81610/useless Del: bad code -- https://master.php.net/note/delete/81610/bad+code Del: spam -- https://master.php.net/note/delete/81610/spam Del: non-english -- https://master.php.net/note/delete/81610/non-english Del: in docs -- https://master.php.net/note/delete/81610/in+docs Del: other reasons-- https://master.php.net/note/delete/81610 Reject -- https://master.php.net/note/reject/81610 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136780) next »