Jump to content

Recommended Posts

Okay, I know I just need to use preg_match_all but there's no output.

 

Here's what I'm trying to extract.  Let's say the tag on the page is

<td width="230"><b>T665</b>

 

I just want to extract the "T665" using preg_match_all

 

echo "Getting Series Number<br>";

$data = file_get_contents("http://www.pagenamehere.php");

preg_match_all('%<b>.*?</b>|.)*?</b>%si', $data, $result, PREG_SET_ORDER);

echo $result[0];

 

 

$str = ' blah blah blah <td width="230">T665</td> blah blah blah
         blah blah blah <td width="765">T999</td> blah blah blah';
preg_match_all('#<td[^>]*>(\w)+</td>#', $str, $matches);
foreach($matches[0] as $val){
   echo $val . '<br />';
}

 

This of course assumes you close your td tag after your 'T665'...(since after your initial <td> tag, you only list T665 and nothing else). It's a very stripped down simple example to help get you started. (I used \w incase you mix numbers, undersacores and letters (both lower and uppercase)). Of course, if you need dashes or anything ele you need to reflect that in the parathesis.

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.