Write (append) text:
//write filename.txt This is a line of text.
Delete a line number:
//write -dl1 filename.txt
Read the entire file:
set %counter 1
while (%counter <= $lines(filename.txt)) {
echo -a $read(filename.txt,%counter)
inc %counter
}
**Place this code inside some event... on text or on input or in an alias, or wherever you want to use it from.
For the above code, just replace the echo -a command with your if/while statement that you mentioned wanting to use. It will read one line at a time and you'll need to look at each line as it is read.
To store a string to a variable:
//set %myvariable This is a string
Or, for a temporary variable:
//var %myvariable This is a string
As far as the PHP thing, you need to look into using Sockets.