bsamson Posted November 14, 2006 Share Posted November 14, 2006 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! Quote Link to comment Share on other sites More sharing options...
Orio Posted November 14, 2006 Share Posted November 14, 2006 bsamson, I already replied to you on the other thread you opened:http://www.phpfreaks.com/forums/index.php/topic,114413.msg467895.html#msg467895Orio. Quote Link to comment Share on other sites More sharing options...
Nicklas Posted November 14, 2006 Share Posted November 14, 2006 To optimize your pattern, you can do something like this:[code=php:0]preg_match_all('~(?<=data">).*?(?=<)|\d{2}/\d{2}/\d{4}~is', $result, $matches);list($phno, $first, $last, $oneyr, $twoyr) = $matches[0];[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.