我正在使用php Querypath,我正在尝试从html字符串中删除html顶部和底部存在的所有空标签。例如:
<div> </div>
<div> </div>
<div>I want remove empty div tag on top and bottom</div>
<div> </div>
<div>other content</div>
<div> </div>
<div> </div>
使用 php 查询路径,我希望更改为:
<div>I want remove empty div tag on top and bottom</div>
<div> </div>
<div>other content</div>
我该怎么办?
使用替换字符串将div 替换为空格。
str_replace(find,replace,from);
因此,您可以在查找中使用<div> </div>
,并将其替换为代码中的""
。