Skip to content

Instantly share code, notes, and snippets.

@hanafiah
Created October 1, 2012 09:52
Show Gist options
  • Save hanafiah/3810625 to your computer and use it in GitHub Desktop.
Save hanafiah/3810625 to your computer and use it in GitHub Desktop.
get html body content
<?php
function getBody($content) {
preg_match("/<body[^>]*>(.*?)<\/body>/is", $content, $matches);
return $matches[1];
}
//test
$html = '<html>
<head>
</head>
<body>
<p><strong><em>GAMBARNYA</em></strong></p>
<ul>
<li><strong><em>A</em></strong></li>
<li><strong><em>B</em></strong></li>
</ul>
<p><strong><em>&nbsp;</em></strong></p>
<p><img src="QBImage/d2125cc2-6add-4ad6-9ec1-0aafcfe33266_1.jpg" alt="" width="295" height="177" /></p>
</body>
</html>';
echo getBody($html);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment