Created
October 1, 2012 09:52
-
-
Save hanafiah/3810625 to your computer and use it in GitHub Desktop.
get html body content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> </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