
本文操作环境:Windows7系统、PHP7.1版、Dell G3电脑。
php怎么修改id元素?
PHP替换字符串中的id元素内容:
如:
$html = '<h1 id="item" class="abc" data="efg">Hello World';
登录后复制修改方法:
$html = '<h1 id="item" class="abc" data="efg">Hello World';
$elementId ="item";
$newString ="Replace World";
$dom = new DOMDocument();
$dom->loadHTML($html);
$belement = $dom->getElementById("$elementId");
$oldString = $belement->nodeValue;
$newHTML = str_replace("$oldString","$newString","$html");
echo $newHTML;登录后复制注意:请更改$elementId和$newString的原始值
推荐学习:《PHP视频教程》
以上就是php怎么修改id元素的详细内容,更多请关注靠谱客其它相关文章!

最后
以上就是淡然翅膀最近收集整理的关于php怎么修改id元素的全部内容,更多相关php怎么修改id元素内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复