By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,748 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,748 IT Pros & Developers. It's quick & easy.

Formatting in PHP

P: n/a
Hi,

I'm a bit of a php noob and I've got a file month1.tmp, and that has this output in it

IP accounting summary
Host: server.local / Time created: 2003/10/21 19:45:57 EST
Data from 2003/09/30 16:59:00 EST to 2003/10/21 19:45:57 EST
download all : 2544M
upload all : 1874M
* 172.16.0.253 user download : 2003M
* 172.16.0.253 user upload : 1169M
* 172.16.0.254 user download : 514M
* 172.16.0.254 user upload : 705M

* = data incomplete, rule was not there all the time

Basically i want to get this output format to another file called month.tmp

Host:server.local
Time:2003/10/21 19:45:57 EST
Data Recorded From 2003/09/30 16:59:00 EST to 2003/10/21 19:45:57 EST
Total Download:2544M
Total Upload:874M
IPAddress:Download:Upload
172.16.0.253:2003M:1169M
172.16.0.254:514M:705M

Is there away i can do this? I'm new to php so i don't know if this is a huge task or not.
It's to be run on a linux system, maybe i should use bash scripting or something?
I want to have the : in there splitting up the data to make it easy to split into fields to use in a web page.

If i'm way out of my depth being a noob then just say so, but if it's fairly easy to do i'd love some guidance :)

--
Thanks
Andrew
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
>Basically i want to get this output format to another file called month.tmp

Well, your is not really a php problem.
You can do the conversion also with bash script, or C, Perl, or something
else.
If you want to do it with php, you must open the .tmp file and start reading
a line at a time.
For every line, you must decide what to do: transfer or modify.
Obviously, you must create the destination file.
You must have r/w permission on server to do that.

Bye
Marco
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.