我有一个HTML字符串来算DIV特定类的如何使用PHP的DOMDocument
html_string = '<div class="quote" post_id="48"
style="border:1px solid #000;padding:15px;margin:15px;" user_id="1"
user_name="rashidfarooq">This is not True</div>
<div class="quote" post_id="49" style="border:1px
solid #000;padding:15px;margin:15px;" user_id="1"
user_name="rashidfarooq">This is good for me</div>
<div class="genuine" post_id="49" style="border:1px
solid #000;padding:15px;margin:15px;" user_id="1"
user_name="rashidfarooq">This is good for me</div>';
我想指望其类名=“引用” 我已经试过
$dom = new DOMDocument;
$dom->loadHTML($html_string);
$divs = $dom->getElementsByTagName('div');
$length = $divs->length;
股利但$长度给出了div的总数。我如何才能只计算具有class name =“quote”的div。有没有可以做到这一点的PHP Native功能。