Jump to content

Recommended Posts

What is the file being used for?

 

Is the file used for data-storage (read/write by a computer)? or is it like a document where it's a bunch of text intended to be read by a human (and not a computer).

 

If it's for data-storage, use a Database or XML (I guess you could use INI - ewwwwww).

A Database would probably be the easiest.

You should be able to do this with fseek.  Fseek moves the file pointer to a certain location.  You can get the middle of the file's location using filesize along with the above function... and divide it by 2.

 

Use fwrite for writing to the file.  And use fopen to open the file to begin with.

 

example

$theFile = fopen("myFile.txt", 'w');
fseek($theFile, (filesize($theFile)/2));
fwrite($theFile, "The middle of the file");

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.