Dale_G Posted May 9, 2008 Share Posted May 9, 2008 Okay, there is webpage which I'm getting through file_get_contents. The part I want to get is this <td align="right" class="head-row"> <div id="numbertext">745</div> <br><br> <div id="numbertext">873</div> <br><br> <div id="numbertext">2324</div> <br><br> </td> But, no all of that, you see the number 745? I'd need to be able to get that number by itself. Don't really need the other numbers, just the first number between the <div id="numbertext"> and the </div> tags. The thing is...the div '<div id="numbertext">' appears multiple times before AND after this block of code, but the '<td align="right" class="head-row">' only appears once, which is why I BELIEVE it needs to be..focused on. Not sure though, basically..you see from the above code, I need to get that number 745 by itself. Thanks guys! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 9, 2008 Share Posted May 9, 2008 Regex. EDIT: Let me write one. @_@ Quote Link to comment Share on other sites More sharing options...
Dale_G Posted May 9, 2008 Author Share Posted May 9, 2008 Regex. EDIT: Let me write one. @_@ Alright, thanks mate. Quote Link to comment Share on other sites More sharing options...
Dale_G Posted May 9, 2008 Author Share Posted May 9, 2008 Hmm, he's offline. Meh, topic is still open, remains "unsolved". Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 <?php $html = <<<HTML <td align="right" class="head-row"> <div id="numbertext">745</div> <br><br> <div id="numbertext">873</div> <br><br> <div id="numbertext">2324</div> <br><br> </td> HTML; $replace = "|\\2|"; $new = eregi_replace("<div ([a-zA-Z0-9 \"=]+)>([0-9]+)</div>", $replace, $html); $new = explode("|", $new); foreach ($new as $v) { if (is_numeric($v)) { $numbers[] = $v; } } print_r($numbers); ?> Worked for me. Quote Link to comment Share on other sites More sharing options...
Dale_G Posted May 10, 2008 Author Share Posted May 10, 2008 As it did for me. Thanks! 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.