我想我不明白。我试图解析一些 html 页面:
<select name="sel">
<option value="val0">-please select me-</option>
<option value="val1">some selection</option>
</select>
我使用 Simple_html_dom 类:
foreach($html->find('select') as $s) {
if ($html->find('option',1) != false) {
$tempoption = $html->find('option',1)->plaintext;
echo $tempoption; //shows 'some selection'
}
}
但是,如果我只是使用这一行:
$value='';
if ( $tempoption == 'some selection')
$value='79';
echo $value; //doesn't shows anything (empty variable?)
//or this one :
if ( strcmp($tempoption, 'some selection'))
$value='79';
echo $value; //Nope.