'', 'message' => '', 'examInfos' => []]; // 保存逻辑 if ($_SERVER['REQUEST_METHOD'] === 'POST') { $id = preg_replace('/[^a-zA-Z0-9]/', '', $_POST['id']); $newConfig = [ 'examName' => $_POST['examName'], 'message' => $_POST['message'], 'room' => ' ', 'examInfos' => [] ]; foreach ($_POST['subject'] as $index => $subject) { $newConfig['examInfos'][] = [ 'name' => $subject, 'start' => $_POST['start'][$index], 'end' => $_POST['end'][$index] ]; } file_put_contents("../configs/{$id}.json", json_encode($newConfig, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); header('Location: index.php'); exit; } // 加载现有配置 if (!empty($id) && file_exists("../configs/{$id}.json")) { $config = json_decode(file_get_contents("../configs/{$id}.json"), true); } ?> 编辑配置

考试科目安排