Skip to content

Instantly share code, notes, and snippets.

@sdwrage

sdwrage/file.php Secret

Last active November 20, 2015 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdwrage/24eb8bd0fa47275e5f52 to your computer and use it in GitHub Desktop.
Save sdwrage/24eb8bd0fa47275e5f52 to your computer and use it in GitHub Desktop.
<?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