Add and remove data to a list PHP
<p>I'm working on an application that uses some saved data to work with it later.
I can't use database so this have to be file based. </p>

<p>The thing works like this:</p>

<ul>
<li>A file name called hosts.txt that contains host:service on every line (diff hosts and services).</li>
<li>My PHP file reads the txt line by line, splits by the delimiter ":" and makes a request with the data that has just recived.</li>
</ul>

<p>Untill here, cool. I also have another file (a HTML form) that allows me to add that at the end of the file. But my problem is the next:</p>

<p>I want to be able to add and remove that from the file so when the next check is done (the check is made every 30 sec) the data should be updated. </p>

<p>Example:</p>

<p>host.txt contains this:</p>

<pre><code>host1:service1
host1:service2
host2:service2
host3:service1
</code></pre>

<p>Now I want to be able to add a new host:service to the list (I've already done this by adding the new data at the end of the text file then that will be included on the next check when php will read again line by line.
Now now, how can I remove a host:service from the file ?</p>

<p>I mean, after reading the file, the PHP will make something like this:</p>

<pre><code>Host: Host1   |    Service: Service1   |  Status: Warning (this will depend on the HTTP request I will make)     (X)
Host: Host1   |    Service: Service2   |  Status: OK     (X)
Host: Host3   |    Service: Service1   |  Status: Critical     (X)
</code></pre>

<p>I want to be able to remove a host:service from the list (and the file) just by clicking that (X). Is this possible guys? I'm a bit lost ( It will be easy for me to work with database but I can't on this project).</p>

<p>I hope I will get something clear.
Thanks in advance,
Regards.</p>
