Jump to content

Grab content in the div


nareshrevoori

Recommended Posts

 

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.

 

Link to comment
Share on other sites

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)?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.