你好,我请求你告诉我简单的 php 脚本来计算特殊的 html 标签,比如字符串中的
。我不知道要试试这个,因为我是 php 的初学者。
最佳答案
您可以使用 DOMDocument
上课。
<?php
$html='<p>Hey hello</p><b>Hey this is bold tag</b><p>Another paragraph</p>';
$dom = new DOMDocument;
$dom->loadHTML($html);
echo $dom->getElementsByTagName('p')->length;// "prints" 2
关于php - 通过php在字符串中计算html标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21746254/