脚本的输出是:“杰出的 1...杰出的 2...杰出的 3...”
例如,如何仅输出数组的第二个位置,以便可以单独输出结果?
像这样: $out[1]
<?php
$html = '
<div class="page-wrapper">
<section class="page single-review" itemtype="http://schema.org/Review" itemscope="" itemprop="review">
<article class="review clearfix">
<div class="review-content">
<div class="review-text" itemprop="reviewBody">
Outstanding 1...
</div>
<div class="review-text" itemprop="reviewBody">
Outstanding 2...
</div>
</div>
</article>
</section>
</div>
<div class="review-text" itemprop="reviewBody">
Outstanding 3...
</div>
';
$dom = new DOMDocument;
$dom->loadHTML ($html);
$xpath = new DOMXPath ($dom);
foreach ($xpath->query (".//div[@class='review-text']") as $review)
{
$out = $review->nodeValue;
echo $out;
}
?>
慕妹3242003
四季花海