【发布时间】:2011-06-15 01:35:16
【问题描述】:
根据SIMPLE HTML DOM PARSER 的文档(在“如何修改HTML 元素”选项卡下),此代码找到<div class="hello"> 的第一个实例:
$html = str_get_html('<div class="hello">Hello</div><div class="world">World</div>');
$html->find('div[class=hello]', 0)->innertext = 'foo';
echo $html; // Output: <div class="hello">foo</div><div class="world">World</div>
如果我想在<div class="hello"> 的last 实例中插入'foo',假设HTML 代码有很多<div class="hello"> 的实例。
应该用什么替换0?
【问题讨论】:
-
您已经提出了 18 个问题并接受了其中仅 7 个问题的答案。改进此统计数据将导致人们更有兴趣帮助您!