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! Link to comment https://forums.phpfreaks.com/topic/104936-solved-strip-all-content-before-and-after-certain-strings-regex-maybe/ Share on other sites More sharing options...
DarkWater Posted May 9, 2008 Share Posted May 9, 2008 Regex. EDIT: Let me write one. @_@ Link to comment https://forums.phpfreaks.com/topic/104936-solved-strip-all-content-before-and-after-certain-strings-regex-maybe/#findComment-537137 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. Link to comment https://forums.phpfreaks.com/topic/104936-solved-strip-all-content-before-and-after-certain-strings-regex-maybe/#findComment-537150 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". Link to comment https://forums.phpfreaks.com/topic/104936-solved-strip-all-content-before-and-after-certain-strings-regex-maybe/#findComment-537168 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. Link to comment https://forums.phpfreaks.com/topic/104936-solved-strip-all-content-before-and-after-certain-strings-regex-maybe/#findComment-537214 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! Link to comment https://forums.phpfreaks.com/topic/104936-solved-strip-all-content-before-and-after-certain-strings-regex-maybe/#findComment-537273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.