For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > May 2006 > Text file manipulation









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Text file manipulation
tony

2006-05-10, 6:58 pm

HI All,

I am trying to write a php script for packet accounting for cisco router. I
have a text file with 1000's of lines, similar to this (the text file will
be updated every minute)

111.10.10.10***24.130.162. 182******************49****************3
360

The *'s are spaces in the file. The amount of spaces in between characters
might also vary, for example if an ip address is longer it might look like:
111.10.10.111**211.130.162. 182*****************49****************33
60

What I need done is to "swop" the IP addresses around and then write the
entire line back to a text file, go to next line in source file swop the ip
address position, write to output file and then proceed to next.

Eg
111.10.10.10***24.130.162. 182******************49****************3
360
becomes
24.130.162.182***111.10.10. 10******************49****************33
60

What will be ideal is that once the script has fully processed all the lines
in the source file - that the file be emptied - or the lines can be erased
from the source file as the processing on that line has been complete and
written to output file.

Thanx in advance
Tony


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com