$orderedCourses = array(); $text; function getCoursesByOrder($listOfCourses, $orderby) { $resultArray = $listOfCourses; // implement here. if ($orderby == 0) { $text = "alphabetical order"; sort($listOfCourses); } else { $text = "alphabetical reverse order"; rsort($listOfCourses); } return $listOfCourses; } $orderedCourses = getCoursesByOrder($listOfCourses, $orderby); if ($orderby == 0) { $text = "alphabetical order"; } else { $text = "alphabetical reverse order"; } //var_dump($orderedCourses); ?> <p> All of courses ordered by <strong><?php echo $text; ?> </strong> are followings : </p> <ol> <?php
} return $resultArray; } ?> <p> All of courses ordered by <strong>alphabetical order</strong> are followings : </p> <ol> <?php $orderby = "0"; if (isset($_GET["orderby"])) { //URL에 news_pages라는 변수가 있냐? $orderby = $_GET["orderby"]; //int로 형변환 해서 가져와 } $orderedCourses = getCoursesByOrder($courseList, $orderby); foreach ($orderedCourses as $courses) { $piece = explode("\t", $courses); if ((int) strlen($piece[0]) > "20") { ?> <li class = "long"><?php echo "{$piece['0']} - {$piece['1']}"; ?> </li> <?php } else { ?> <li><?php echo "{$piece['0']} - {$piece['1']}"; ?> </li>
$resultArray = $listOfCourses; // implement here. if ($orderby == 0) { sort($resultArray); } elseif ($orderby == 1) { rsort($resultArray); } return $resultArray; } if (isset($_GET["orderby"])) { $orderby = $_GET["orderby"]; } if (!$orderby) { $orderby = 0; } $orderedCourses = getCoursesByOrder($lines, $orderby); ?> <p> All of courses ordered by <strong>alphabetical order</strong> are followings : </p> <ol> <?php foreach ($orderedCourses as $get) { $temp = explode("\t", $get); if (strlen($temp[0]) > 20) { ?> <li class="long"><?php echo $temp[0] . " - " . $temp[1]; ?> </li> <?php
$stringnumber = strlen($key); if ($stringnumber > 28) { ?> <li class="long"><?php echo $key; ?> </li><?php } else { echo $key, "<br>"; } } } } return $resultArray; } getCoursesByOrder(file("courses.tsv"), 0); ?> </div> <div class="section"> <h2>Adding Courses</h2> <!-- Ex. 5: Adding Courses & Ex 6: Query Parameters --> <p>Input course or code of the course doesn't exist.</p> </div> </div> <div id="footer"> <a href="http://validator.w3.org/check/referer"> <img src="http://selab.hanyang.ac.kr/courses/cse326/2015/problems/images/w3c-html.png" alt="Valid HTML5" /> </a> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img src="http://selab.hanyang.ac.kr/courses/cse326/2015/problems/images/w3c-css.png" alt="Valid CSS" /> </a>
} if (isset($_GET['orderby'])) { $startCharacter = $_GET['orderby']; if ($_GET['orderby'] == "") { $startCharacter == 0; } } else { $startCharacter = 0; } ?> <p> All of courses ordered by <strong>alphabetical order</strong> are followings : </p> <ol> <?php $array = getCoursesByOrder($courses, $startCharacter); foreach ($array as $line) { if (strlen($line) > 30) { print "<li class=\"long\">{$line}</li>"; } else { print "<li>{$line}</li>"; } } ?> </ol> </div> <div class="section"> <h2>Adding Courses</h2> <!-- Ex. 5: Adding Courses & Ex 6: Query Parameters --> <?php if (isset($_GET['new_course']) && isset($_GET['code_of_course']) && $_GET['new_course'] != "" && $_GET['code_of_course'] != "") {
{ $resultArray = $listOfCourses; if ($orderby == 0) { sort($resultArray); } elseif ($orderby == 1) { rsort($resultArray); } return $resultArray; } ?> <p> All of courses ordered by <strong>alphabetical order</strong> are followings : </p> <ol> <?php $orderedCourses = getCoursesByOrder($filename, $orderby); foreach ($orderedCourses as $getCourse) { $getCourse2 = explode("\t", $getCourse); $getCourse3 = implode("-", $getCourse2); ?> <li> <?php echo $getCourse3; ?> </li> <?php } ?> </ol> </div> <div class="section"> <h2>Adding Courses</h2>
function getCoursesByOrder($listOfCourses, $orderby) { $resultArray = $listOfCourses; if ($orderby == 0) { sort($resultArray); } else { rsort($resultArray); } return $resultArray; } if (isset($_GET['orderby'])) { $orderby = $_GET['orderby']; } else { $orderby = 0; } $sortedArray = getCoursesByOrder($line, $orderby); if ($orderby == 0) { ?> <p> All of courses ordered by <strong>alphabetical order</strong> are followings : </p> <?php } else { ?> <p> All of courses ordered by <strong>alphabetical reverse order</strong> are followings : </p> <?php } ?>
$resultArray = $listOfCourses; if ($orderby == 0) { sort($resultArray); } else { rsort($resultArray); } return $resultArray; } ?> <p> All of courses ordered by <strong>alphabetical order</strong> are followings : </p> <ol> <?php foreach (getCoursesByOrder($newArr, $orderby) as $p) { $tempCourse = explode(" -", $p); if (strlen($tempCourse[0]) > 20) { ?> <li class="long"><?php echo $p; ?> </li> <?php } else { ?> <li><?php echo $p; ?> </li> <?php
$text; if (isset($orderby) and $orderby == 0) { $text = "Alphabetical order"; } else { $text = "Alphabetical reverse order"; } ?> <p> All of courses ordered by <strong><?php echo "{$text} {$orderby}"; ?> </strong> are followings : </p> <ol> <?php $arr = getCoursesByOrder($listOfCourses, $orderby); foreach ($arr as $content) { if (strlen($content) - 8 <= 20) { ?> <li><?php echo $content; ?> </li> <?php } else { ?> <li class="long"><?php echo $content; ?> </li>
{ $resultArray = $listOfCourses; if ($orderby == 0) { sort($resultArray); } else { if ($orderby == 1) { rsort($resultArray); $ordering = "alphabet reverse order"; } else { print "Input error."; exit(1); } } return $resultArray; } $orderedlist = getCoursesByOrder($lines, $orderby); ?> <p> All of courses ordered by <strong><?php echo $ordering; ?> </strong> are followings : </p> <ol> <?php foreach ($orderedlist as $orderedlist2) { $tmp5 = explode("\t", $orderedlist2); $tmp6 = implode(" - ", $tmp5); if (strlen($tmp5[0]) > 20) { ?> <li class = "long"><?php