Forum Moderators: coopster

Message Too Old, No Replies

get file contents

         

mooger35

9:24 pm on Oct 9, 2007 (gmt 0)

10+ Year Member



I'm trying to remember how I did this in the past but I'm drawing a blank.

I'm trying to pull information from another site to post on mine.

the content I'm trying to get out comes after the "<pre>"

ex.
<pre> Standings P W D L F A Pts
1 team-A 6 4 2 0 14 4 14
2 team-B 6 4 1 1 15 6 13
-------------------------
3 team-C 6 3 3 0 12 6 12
... etc etc

What I'd like to do is remove everything except:
1 team-A 14
2 team-B 13
3 team-C 12

When doing this in the past I think I used to stick the file contents into an array but I'm not 100% sure.

coopster

10:14 pm on Oct 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Probably, and if you are going to do that, use file() as opposed to file_get_contents(). Then you can loop through and use a regular expression to evaluate and parse each line.

mooger35

10:34 pm on Oct 9, 2007 (gmt 0)

10+ Year Member



Thanks... gets me on the right track.

now I'm trying to find the array key where the value = "<pre> Standings P W D L F A Pts"

array_keys seems to returning nothing.

Is there another way?

eelixduppy

10:35 pm on Oct 9, 2007 (gmt 0)



The index for the first line should be 0. Since that info is just the "heading" of the information, you can omit that is your manipulation and start from the index 1.

mooger35

10:39 pm on Oct 9, 2007 (gmt 0)

10+ Year Member



I've still got all the lines of code in my array.

My thinking was find the key with the header I'm looking for and then grab the next 4 rows of information.

mooger35

10:53 pm on Oct 9, 2007 (gmt 0)

10+ Year Member



Got it... used preg_match within a foreach.

Seems to get me what I'm looking for.

Thanks guys.