Parsing remote data - Need help


I am accessing a php page that I append a username to and I receive back a text file containing data such as this. I always get 2 lines of data, and there are always 7 fields.


I really only need to keep the second line of data, ie: skip the first line, but I need to parse it out into 7 strings, so I can print only the strings I need. I am pretty new to php, or any language as far as that goes. Can someone give me a clue here?

I have tried using fopen and include to be able to grab the data, but the backslashes are killing me. I can’t get anything to parse correctly.


I would look in to using the following functions:


Links on how to use them:

These should make it quite simple to get the job done. :)


or explode()



$pieces = explode("", $data);
echo $pieces[0];
echo $pieces[1];

Doesn’t work.


Just wondering, but why doesn’t explode() work? Also if that doesn’t did you try using what I gave you?


Can you give me an example using :



explode should work (and it’s the easiest way) - what results did you get that were invalid?

the other way is something like

variable to hold offset
    array[element] = substr($string, strpos($string, $needle, $offset))
    add the current strings lenght the the offset variable
end loop

or you could do a regrex - which would be faster but you have to know how to do it.

Again explode is the easiest way.


The explode code should work fine, perhaps it’s something with the backslashes, like they are being escaped/not being escaped, or something? That’s the only thing I can think of…


Well, I would imagine in the code example above, this line is the problem.


The closing quote is being escaped, which no doubt will result in a parse error.

Does the data have to use backslashes? Try using | instead.