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].

Link to comment
Share on other sites

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>';

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.