Jump to content

[SOLVED] unable to pull proper information


9three

Recommended Posts

Hey,

 

<?php
$gold = file_get_contents('http://www.site.com/');
preg_match_all('~<td class="td" align="Right">(.+?)</td>~is', $gold, $goldMatch);

foreach ($goldMatch[0] as $gMatched)
  echo $gMatched[2].'<br>';

?>

 

When I run this code there are about 8 matches that come up. Out of those 8 I only need 3. So I tried to change it to

 

echo $gMatched[2];

 

But all it outputted was a string 'd'. How can I only use what I need? I need [2], [5], and [7].

thanks that worked well sasa. I got a problem though, its out putting it 7 times. I don't know why it would do it 7 times as there are 8 matches in total. Either way it should display only once :/

 

968.00
968.00
968.00
968.00
968.00
968.00
968.00

 

updated file:

<?php
$gold = file_get_contents('http://www.site.com/');
preg_match_all('~<td class="td" align="Right">(.+?)</td>~is', $gold, $goldMatch);

foreach ($goldMatch[0] as $gMatched)
  echo $goldMatch[0][1].'<br>';

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.