Regular Expression to get contents of div[id]


/ Published in: PHP
Save to your folder(s)

This allows you to get contents of any div with ID tag.
$matches[0] returns with parent div tag
$matches[1] returns with out parent div tag


Copy this code and paste it in your HTML
  1. preg_match('/\<div id\=[\"]{0,1}ad_content[\"]{0,1}\>(.*?)\<\/div\>/s', $content['content_body'], $matches);
  2. $content['content_body'] = $matches[1];

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.