<br/> <?php if ($_POST) { if (isset($_POST["text"])) { if (!empty($_POST["text"])) { $seminarsInfo = array(); // I assume that the input will always be valid and in the format provided // (for example, no dash in the seminar title) preg_match_all('/(.*?)\\-(.*?)\\-(\\d{2}-\\d{2}-\\d{4}\\s+\\d{2}:\\d{2})\\s+(.*)/', $_POST["text"], $seminarsInfo, PREG_SET_ORDER); $seminars = array(); foreach ($seminarsInfo as $seminarInfo) { $seminars[] = new Seminar($seminarInfo[1], $seminarInfo[2], $seminarInfo[3], $seminarInfo[4]); } $field = $_POST["field"]; $order = $_POST["order"]; if (Seminar::validateOrderByParameters($field, $order)) { uasort($seminars, Seminar::orderBy($field, $order)); } echo displaySeminarsTable($seminars); } else { echo "<div class=\"error\">Invalid field or order.</div>"; exit; } } else { echo "<div class=\"error\">No text provided.</div>"; exit; } } function displaySeminarsTable($seminars) { $result = "<table border=\"1\" class=\"seminars-table\">";