Created
April 21, 2021 09:35
-
-
Save cockok/335f066393cfcd889e51c01fafb4e9b3 to your computer and use it in GitHub Desktop.
HTMLのタグを補完し正規化する
This file contains hidden or 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 | |
$html = '<p>hoge'; | |
$dom = new DOMDocument(); | |
$dom->loadHTML('<?xml encoding="utf-8" ?>' . $html); | |
$html = str_replace(['<html><body>', '</body></html>'], '', $dom->saveHTML($dom->documentElement)); | |
echo $html; | |
// <p>hoge</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment