Re: Pulling Data From a Loop
| From: | Mike Gifford | Date: | Tue, 27 Jun 2000 01:57:09 +0000 |
| Subject: | Re: Pulling Data From a Loop | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3268@lists.php.net to get a copy of this message | ||
Hi David,
Thanks for your prompt reply.
David Robley wrote:
> On 26 Jun, Mike Gifford wrote:
> Couple of things you could try;
I was able to get it working with the following code:
<?
$page3 = "wtowatch3.txt";
$fd = fopen("$page3", "r");
$rdf2a = "";
while ($buffer = fgets($fd, 4096)) {
$buffer = eregi_replace( "(<link>.*</item>)(<title>.*</title>)",
"\\2
\n \\1 \n", $buffer);
$buffer = eregi_replace( "</link>", "</link>\n", $buffer );
$rdf2a .= $buffer;
}
fclose($fd);
echo $rdf2a;
?>
I didn't come up with this solution, but a friend did who was
rollerblading by in my time of need.
However, I am curious exactly how your solutions would work.
> using list and each to loop through the array $rdf2a and echo the
> individual elements
I tried this as best as I could, using each and list individually. From
what I can tell though (from the PHP Manual) these should be used
together for the desired effect. Unfortunately, the example is written
assuming that you know something about programming.
> using implode to put the contents of the array in a string which you
> can then echo
Wasn't able to get this to work either. I think that I was initially
stumped with how to turn this into an array. I tried to involve a
counter variable, but my limited knowledge of arrays got in my way.
> appending $buffer to itself/another variable which you can then echo
> outside the loop
Actually, this is much like the solution that my friend suggested
above... So I guess I don't need any further help with this option...
Thanks for furthering my education..
Mike
--
Mike A. Gifford OpenConcept Consulting
Mike@OpenConcept.On.Ca Http://www.OpenConcept.On.Ca
Web Design, Hosting, Graphic Design & Site Promotion
Featured Site --> Http://WTOAction.Org