感謝那些讓我我需要拆分的文件並加載件爲陣列的信息。從陣列中,我可以讓表單選擇適當的顯示卡。
我這是怎麼加載的文件:
$deck1 = [];
$maincount = 0;
$handle = @fopen("Deck1.dec", "r");
if ($handle) {
while (($buffer = fgets($handle, 4096)) !== false) {
preg_match_all("#mvid:(\d+)\s+qty:(\d+)\s+name:([^:]+):(\w+)#", $buffer, $matches);
$count = count($matches[1]);
for($i = 0; $i < $count; $i++) {
$deck1[$maincount][1] = $matches[1][$i];
$deck1[$maincount][2] = $matches[2][$i];
$deck1[$maincount][3] = rtrim($matches[3][$i], " loc");
$deck1[$maincount][4] = $matches[4][$i];
}
$maincount++;
}
//echo "<pre>".print_r($deck1, true);
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($handle);
}
而且我這是怎麼創建單選按鈕。我需要在全球範圍內刪除某些卡片。
foreach ($deck1 as $index=>$option) {
if ($option[3] != "Plains" && $option[3] != "Forest" && $option[3] != "Mountain" && $option[3] != "Swamp" && $option[3] != "Island"){
if ($option[4] == "SB"){
echo "<i><input type=\"radio\" name='mText7bgo' value=\"{$option[1]}\">{$option[3]}</i><br>";
}
else {
echo "<input type=\"radio\" name='mText7bgo' value=\"{$option[1]}\">{$option[3]}<br>";
}
}
}
我確定有一些優化工作可以完成,但這樣做完成了工作。謝謝。
代碼在哪裏? –
http://php.net/manual/en/function.file.php –
你已經試過了什麼?做些努力,而不是僅僅在這裏拋出完整的問題/任務。 – jwenting