Jump to content

Issue grabbing info w/ regex ...


bsamson

Recommended Posts

Here's the situation. I have the following code:

[code]<div class="stacked">
<div class="basicBox">
<h2>Customer Information</h2>
<br />
<table width="100%" border="1" cellpadding="0" cellspacing="0" class="confirmForm tighter">
<tr>
<td class="label">Phone Number:</td>
  <td class="data">123-456-7890</td>
</tr>
          <tr>
<td class="label">First Name:</td>
<td class="data">GEORGE</td>
</tr>
<tr>
<td class="label">Last Name:</td>
  <td class="data">JOHNSON</td>
</tr>
</table>
<div class="hrTight"></div>
<h2>Phone Upgrade Program Results</h2>
<div class="hrTight"></div>
  <div id="rebtable">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
  <th class="headborder">Savings Amount</th>
  <th> Eligibility Date</th>
</tr>
<tr>
  <td class="displaycell">
    Up to $75 with a two-year subscriber agreement<br>
    (or up to $25 with a one-year agreement)
  </td>
               <td>06/01/2006</td>
</tr>
<tr><td colspan="2"><hr width="100%"/></td></tr>
<tr>
   <td class="displaycell">
     Up to $150 with a two-year subscriber agreement<br>
    (or up to $75 with a one-year agreement)
   </td>
               <td>04/01/2007</td>
</tr>
</table>
  </div>[/code]

Now, I am attempting to grab some info from this page with this:

[code]$result=(THE PAGE W/ THE ABOVE CODE)
$regex = "/<td class=\"label\">Phone Number:<\/td>.*?<td class=\"data\">(.*?)<\/td>.*?<td class=\"label\">First Name:<\/td>.*?<td class=\"data\">(.*?)<\/td>.*?<td class=\"label\">Last Name:<\/td>.*?<td class=\"data\">(.*?)<\/td>.*?<td>([0-9]{2}\/[0-9]{2}\/[0-9]{4})<\/td>.*?<td>([0-9]{2}\/[0-9]{2}\/[0-9]{4})<\/td>/is";

preg_match_all($regex, $result, $matches);

$phno =  $matches[1][0];
$first = $matches[2][0];
$last = $matches[3][0];
$oneyr = $matches[4][0];
$twoyr = $matches[5][0];[/code]

Could I please get some help figuring out why $phno, and $first are not storing the info I need? Thanks for any help!

Link to comment
https://forums.phpfreaks.com/topic/27230-issue-grabbing-info-w-regex/
Share on other sites

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.