Page 1 of 1
Simple Parsing
Posted: Tue Feb 01, 2005 9:43 am
by rdionne1187
hello, I have put together a parser that parses a file on my server. I used the file() function so I have an array of each line, the question is that I want to split each line up into different parts. Should I use the tokenizer, or is there an easier way to split up different my arrays? also, the strings in the file that I want to parse are surrounded by "< >" thingys if that would affect the way one of you would choose to do this.
Posted: Tue Feb 01, 2005 9:49 am
by feyd
please post some examples of the data and what you'd like to see so we can best direct you.
Posted: Tue Feb 01, 2005 4:28 pm
by rdionne1187
I have this file downloaded to the server each time the script is run
Code: Select all
<1> <*їMYC4T]*THE N()()B> <STEAM_0:1:3969474> <5276> <1999> <51> <1569> <2.639>
<2> <Knife goes in which hole?> <STEAM_0:1:1592947> <545> <269> <11> <170> <2.026>
<3> <*їMYC4T]* †RICK†> <STEAM_0:1:4724878> <2542> <1333> <47> <1040> <1.907>
<4> <-†-V!k!ng3n.MP3> <STEAM_0:0:1656257> <665> <473> <10> <203> <1.406>
<5> <їArfen] NickIce101> <STEAM_0:0:6123007> <1058> <952> <20> <362> <1.111>
<6> <їC4T] Jalks> <STEAM_0:1:5638383> <735> <671> <5> <339> <1.095>
<7> <~ { AoM } ~ incubus_113> <STEAM_0:0:3390824> <536> <504> <13> <139> <1.063>
<8> <*їMYC4T]*Skarfunkly> <STEAM_0:0:2652297> <1023> <1065> <49> <396> <0.961>
<9> <Vagrant> <STEAM_0:0:5861680> <586> <643> <8> <201> <0.911>
<10> <{ C4T } AfTEr_SHoCK> <STEAM_0:0:6113508> <1499> <1999> <99> <426> <0.750>
I want to separate each line into different parts by the numbers or names inside the < >'s
so i used the file($myfile) and i have an array now with myfile, i want to separate $myfile[0] into $myfile[0]['place'] and $myfile[0]['Name']
and so one, is there an easier funtion i can use to split them up how I like?
Posted: Tue Feb 01, 2005 6:34 pm
by feyd
preg_split() is probably the best direction to go. After it's turned into a numeric array, you can rebuild it into named indicies.
Posted: Tue Feb 01, 2005 8:28 pm
by rdionne1187
thanks