I'd take the results of file() and then
walk through the array looking for the lines for the
various fruit you're concerned with.  Then I'd grab the next
two lines and process them, with something like:

$line = "<td align=left>.46</td>";

ereg('^<td align=(left|right)>([^<]+)</td>',$line,$m);

echo $m[1] . "\n";
echo $m[2] . "\n";

IMHO, it's bad to do this kind of thing because any change in
the content means a breakage of your processing code.  I
think that using something like XML or the DOM may be a
better approach.  Individuals with knowledge in this area can
speak more to this idea.

Good luck.

Andy


On Sat, Aug 18, 2001 at 09:48:11PM -0500, Craig Westerman wrote:
> I'm reading a book and have a little confusion in my mind.
> Consider the following table. Assume that I grabbed it from another web site
> using:
> <?
> $url = 'http://www.abc123xyz.com';
> $lines_array = file($url);
> $lines_string = implode('', $lines_array);
> ?>
> 
> =======================================
> 
> <html><body>
> <table cellspacing="2" cellpadding="2" border="0">
> <tr>
> <td align=center>banana</td>
> <td align=left>.46</td>
> <td align=right>.55</td>
> </tr>
> <tr>
> <td align=center>pear</td>
> <td align=left>.38</td>
> <td align=right>.51</td>
> </tr>
> <tr>
> <td align=center>apple</td>
> <td align=left>.59</td>
> <td align=right>.33</td>
> </tr>
> </table>
> </body></html>
> 
> =======================================
> 
> The fruit lables don't change, but prices change daily.
> How would I parse JUST the two prices to the right of the word pear into a
> new html table?
> 
> How would I parse the word pear AND the two prices to the right into a new
> html table?
> I think the answers will help me understand better.
> Thanks
> Craig ><>
> [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
--------------------------------------------------
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to