我有以下div,
<div class="info">
Review Status: <span style="color:green;"><strong>Active</strong></span>
| Order #:
<strong>
22436 </strong>
| Transaction Date:
<strong><span class="mm_panel_text">
3/28/15 </span>
</strong>
<div class="separator-small"></div>
<div class="separator-small"></div>
<a href="/survey/flag/9287742"><i class="fa fa-flag"></i> Flag Review »</a>
<a href="/user/contact/nintytwomw/comment/9287742"><i class="fa fa-envelope"></i> Email reviewer »</a>
<a href="javascript:view_detail(8713492)"><i class="fa fa-search"></i> View details »</a>
<a href="/survey/reply/9287742"> <i class="fa fa-bullhorn"></i> Post public reply »</a>
<a href="#" id="lnk_commentFeature_8713492" data-id="8713492" data-featured="no"><i class="fa fa-star"></i> Feature</a>
<!-- End Seller admin edit options -->
<div class="separator"></div>
<h3 class="subheader">Tag Review <a href="#" data-reveal-id="user_terms"><i class="fa fa-question-circle"></i></a></h3>
<ul class="tagdisplay taglist" survey_id="8713492" tags="[]"></ul> <div class="separator"></div>
</div>
现在我想访问class =&#34; mm_panel_text&#34;并获取内容date.I写了一个代码,但它没有工作。
foreach($html1->find('span[class="mm_panel_text"]') as $transaction_date){
$transactionDate[] = $transaction_date->innertext;
// $rating[] = $ratings->plainText;
if (sizeof($transactionDate)==15) {
var_dump($transactionDate);
}
//var_dump($links);
}
这门课有很多div。所以我使用循环访问所有元素&#39;内容。代码有什么问题?它没有任何显示。
答案 0 :(得分:1)
这样就可以了。
$transactionDate = $html1->find('span[class="mm_panel_text"]')->plaintext ;
或者
$transactionDate = $html1->find('span[class=mm_panel_text]')->plaintext ;
编辑:
如果循环遍历所有具有类mm_panel_text
的div,则可以执行此操作
foreach($html1->find('span.mm_panel_text') as $transaction_date)