Hi all.

I have a text file and it will be edited by multiple people at one time. I want to be able to have a script to do this for me, given the new text, the old text and if possible how many people have been editing it.

I have nothing to show for this so far, however I have done quite a bit of research and haven't found anything yet.

Either a script or even a pint in the right direction will be greatly valued. Thanks :)

I'm not surprised you have nothing to show for this so far!!!
I think you are in for a big disappointment!
And I don't think you know what you are asking for either.

The internet delivers data to each user, and they get a copy on their computer. There is no connection between the users. Nor to the original file. So there is no way that you can set up collaborative editing with a little PHP script. You need something special that links all the computers that are looking at the text together and transmits every mouse movement, every click, every keyboard press back and forth between the users.

Somehow, I don't think you'll be doing that with a simple PHP script!

Collaborative editing can be done over the internet - it was part of the legendary Mother of All Demos, back in 1968 - but you need a specialist tool to do this.

Try Google on collaborative editors to see what exists to enable many users to edit a file at once. It can be done.

Why do you wish to have multiple people editing a file at the same time??? It's a very unusual requirement.

Oh, that's annoying :/

At the moment I have an edited version of Mozilla labs Bespin, that saves a file, but at the moment if one person saves then the other will overwrite it on their save.

I had heard Bespin has a collaborative mode but I think that's for a different version than the one I have

That is totally normal.
The overwriting is known as the lost update problem, when two people edit something and save, the second save always overwrites the first one. In databases we use row locking and table locking to overcome this, which is why some databases can only ever be standalone and not shared - they don't all have locking mechanisms.
The problem arose the day they invented networks and gave more than one user access to edit a common file. I.E. it is a decades old problem, that everyone knows about.

It's a big problem and is not easy to solve. If you read the Wikipedia article on collaborative editing, you'll see it mentioned that it was demoed in the Mother of All Demos, but took decades to implement.

You still haven't said why on earth you want several people editing a file simultaneously. It is a very unusual requirement to need.

so I may need to use a database?

I want to make a collaborative editor basically, purely as a technical exercise but also as a possible app to release.