这是html代码:
<?
$html ='<table cellspacing="0" cellpadding="0" class="mytable">
<tr>
<th class="first-td">Home <span>Live</span></th>
<th>type</th>
<th>Status</th>
</tr>
<tr>
<td width="40%" class="first-td">text1</td>
<td>info</td>
<td class="status"><span class="identify">asdf2</span></td>
</tr>
<tr>
<td width="40%" class="first-td">text2</td>
<td>info</td>
<td class="status"><span class="identify2">asdf</span></td>
';
$pattern = '/<span class="identify">(.*?)<\/span>/im';
preg_match_all($pattern, $html, $matches);
print_r($matches);
?>
但我想要的是取回单词text,这是该单元格中识别的单元格中的td。或者,如果类在识别打印1时更容易,或者如果它是识别2,则按0。
所以我想像这样伪代码:
If class-identify print the td-class=first-td of that cell