-
-
Save sdwrage/24eb8bd0fa47275e5f52 to your computer and use it in GitHub Desktop.
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 | |
public function parseBodyContent($string, $file) | |
{ | |
$dom = new \DOMDocument('1.0', 'UTF-8'); | |
$dom->loadHTML($string); | |
$bodyTags = $dom->getElementsByTagName('body'); | |
if (!empty($bodyTags)) { | |
$body = $bodyTags->item(0); | |
$content = (string) $dom->saveHTML($body); | |
} else { | |
$formattedFile = strstr($file, 'projects'); | |
$content = "Error: Missing a body tag in " . $formattedFile . "."; | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment