我需要使用 PHP 通过 ID 搜索元素,然后将 html 内容附加到它。这看起来很简单,但我是 php 新手,找不到合适的函数来执行此操作。
$html = file_get_contents('http://example.com');
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($html);
$descBox = $doc->getElementById('element1');
Run Code Online (Sandbox Code Playgroud)
我只是不知道下一步该怎么做。任何帮助,将不胜感激。