|
-
Aug 5th, 2007, 10:34 PM
#1
Thread Starter
Addicted Member
Writing to a file?
I know how to write to a file, but I want to know if its possible to write to a certain part of the file? The code I use to write text to a file:
PHP Code:
$support="Name: " . $name . "\nMessage: " . $msg . "\nEmail: " . $email . "\nDate: " . $Date;
$fp=fopen("support.php", "a+");
fwrite($fp, $support);
fclose($fp);
How would I make that write after and before some code? So the code looks like this:-
Code:
<HTML><TITLE>Support</TITLE>
<br/><br/>
Name: my name
Message: my message
Email: myemail
Date: 06 August 2007
</HTML>
-
Aug 5th, 2007, 10:46 PM
#2
Re: Writing to a file?
you want to append the text then:
PHP Code:
fopen($filename, 'a')
My usual boring signature: Something
-
Aug 5th, 2007, 10:50 PM
#3
Thread Starter
Addicted Member
Re: Writing to a file?
I already do that, but I want it to write to a certain part of the file (before </html>)
-
Aug 5th, 2007, 10:57 PM
#4
Re: Writing to a file?
try reading the contents of the folder to a string, then ad the info to the begining of the string. And add it to the file.
PHP Code:
$fp = foppen("file", "a+");
$content = fread($fp);
$string = "Add this to begining";
$content = $string . $content;
$write = fwrite($fp, $content);
fclose($fp);
Last edited by dclamp; Aug 5th, 2007 at 11:02 PM.
My usual boring signature: Something
-
Aug 5th, 2007, 11:18 PM
#5
Thread Starter
Addicted Member
Re: Writing to a file?
If I did that it'll repeat the code in the file.
-
Aug 5th, 2007, 11:20 PM
#6
Re: Writing to a file?
show me what you want to add to the beginning of the file
My usual boring signature: Something
-
Aug 5th, 2007, 11:25 PM
#7
Thread Starter
Addicted Member
Re: Writing to a file?
Code:
<HTML><TITLE>Support</TITLE>
<br/><br/>
Then the message and after the message:-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|