Formatting in PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GiJO

    #1

    Formatting in PHP

    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.loc al
    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:Downl oad:Upload
    172.16.0.253:20 03M:1169M
    172.16.0.254:51 4M: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


  • Marco Napolitano

    #2
    Re: Formatting in PHP

    >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


    Comment

    Working...