如何通过从文本文件中读取选择标签的选项值来选择它,下面是我的代码,
文本文件:txt.txt
SUBMISSION TYPE:PRIORITY
php:
$filename = 'txt.txt';
$str = file_get_contents($filename);
$data = explode("\n", $str);
for ($z=0; $z<=1; $z++){
$data[$z] = explode(":", $data[$z]);
}
for ($y=0; $y<=1;$y++){
if($data[$y][0]=="SUBMISSION TYPE"){
$submissiontype= $data[$y][1];}
}
HTML:
<th>Submission Type: <title="Submission Type"></th>
<td><select id="submission" name="submission" autocomplete="off">
<option value="NORMAL"<?php echo strcmp($submissiontype, 'NORMAL') === 0 ? ' selected' : ''; ?> >NORMAL</option>
<option value="PRIORITY"<?php echo strcmp($submissiontype, 'PRIORITY') === 0 ? ' selected' : ''; ?>>PRIORITY</option>
<option value="PAPERSTUDY"<?php echo strcmp($submissiontype, 'PAPERSTUDY') === 0 ? ' selected' : ''; ?>>PAPERSTUDY</option>
</td>
谁能指出这段代码中的错误?
代码的 HTML 嵌入 PHP 部分不起作用,提交类型值始终被选为 NORMAL,即使我将其作为优先级。