nareshrevoori Posted December 2, 2009 Share Posted December 2, 2009 I've been trying to figure out this but nothing helps I am not very good with Regx. I want to grab the content (text to grab & date part ) in the 2nd <div class="section"> and put them in a php array. $html = '<div class="pad"> <div class="section"> <div class="section_title">Title text</div> </div> <div class="section border_top"> <div><small>Info.</small></div> </div> <div class="section"> <div class="section border_top"> <a href="#">link</a> text to grab <small>12/2/2009</small></div> <div class="section border_top"> <a href="#">link</a> text to grab <small>12/2/2009</small></div> <div class="section border_top"> <a href="#">link</a> text to grab <small>12/2/2009</small></div> <div class="section border_top"> <a href="#">link</a> text to grab <small>12/2/2009</small></div> <div class="section border_top"> <a href="#">link</a> text to grab <small>12/2/2009</small></div> </div> </div>'; thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/183683-grab-content-in-the-div/ Share on other sites More sharing options...
nareshrevoori Posted December 2, 2009 Author Share Posted December 2, 2009 I am not using php 5, so DOMDocument is out of choice Quote Link to comment https://forums.phpfreaks.com/topic/183683-grab-content-in-the-div/#findComment-969510 Share on other sites More sharing options...
cags Posted December 2, 2009 Share Posted December 2, 2009 If you don't use PHP 5 you really should consider upgrading. There is always DOMXML, which is the suggested alternative for PHP 4. Of course it can be done with Regular Expressions, but we would need to know how accurate your example is. For example is the date always inside <small> tags? Is the href of the anchor links always # (I assume not)? Same applies for the anchor link text. What characters can be included in "text to grab"? Will it include any tags or special tag characters (> < etc)? Quote Link to comment https://forums.phpfreaks.com/topic/183683-grab-content-in-the-div/#findComment-969684 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.