Пример #1
0
    //                implement here.
    foreach ($listOfCourses as $lc) {
        $temp = explode("\t", $lc);
        if ($temp[0][0] == $startCharacter) {
            array_push($resultArray, $lc);
        }
    }
    return $resultArray;
}
if (isset($_GET["character"])) {
    $character = $_GET["character"];
}
if (!$character) {
    $character = 'C';
}
$searchedCourses = getCoursesByCharacter($lines, $character);
?>
        <p>
            Courses that started by <strong><?php 
echo $character;
?>
</strong> are followings :
        </p>
        <ol>
            <?php 
foreach ($searchedCourses as $sc) {
    $temp = explode("\t", $sc);
    ?>
                <li><?php 
    echo $temp[0] . " - " . $temp[1];
    ?>
Пример #2
0
} else {
    $startCharacter = "C";
}
$searchedCourses = array();
function getCoursesByCharacter($listOfCourses, $startCharacter)
{
    $resultArray = array();
    //                implement here.
    foreach ($listOfCourses as $course) {
        if (substr($course, 0, 1) == $startCharacter) {
            $resultArray[] = $course;
        }
    }
    return $resultArray;
}
$searchedCourses = getCoursesByCharacter($listOfCourses, $startCharacter);
//var_dump($searchedCourses);
?>
        <p>
            Courses that started by <strong>'<?php 
echo $startCharacter;
?>
'</strong> are followings :
        </p>
        <ol>
			<?php 
foreach ($searchedCourses as $course) {
    ?>
				<li><?php 
    echo $course;
    ?>
Пример #3
0
    if ($_GET['character'] == "") {
        $inputChar = "C";
    }
} else {
    $inputChar = "C";
}
?>

            Courses that started by <strong><?php 
echo $inputChar;
?>
</strong> are followings :
        </p>
        <ol>
            <?php 
$arrayToPrint = getCoursesByCharacter($courses, $inputChar);
foreach ($arrayToPrint as $lines) {
    print "<li>{$lines}</li>";
}
?>
        </ol>
    </div>
    <div class="section">
        <h2>List of Courses</h2>
<!-- Ex. 4: List of Courses & Ex 6: Query Parameters -->
        <?php 
$startCharacter = 0;
function getCoursesByOrder($listOfCourses, $orderby)
{
    $resultArray = array();
    //                implement here.
Пример #4
0
if (isset($_GET["character"])) {
    //URL에 news_pages라는 변수가 있냐?
    $character = $_GET["character"];
    //int로 형변환 해서 가져와
}
?>
        <p>
            Courses that started by <strong>'<?php 
echo $character;
?>
'</strong> are followings :
        </p>
        <ol>
            <?php 
$courseList = file("courses.tsv");
$searchedCourses = getCoursesByCharacter($courseList, $character);
foreach ($searchedCourses as $courses) {
    ?>
                <?php 
    $piece = explode("\t", $courses);
    ?>
                    <li><?php 
    echo "{$piece['0']} - {$piece['1']}";
    ?>
</li>
                <?php 
}
?>
        </ol>
    </div>
    <div class="section">
Пример #5
0
    $number = 1;
    echo "Courses that started by";
    echo " ' ", "<strong>{$startCharacter}</strong>", " ' ";
    echo " are followings : ", "<br><br>";
    for ($i = 0; $i < count($resultArray); $i++) {
        $string = $resultArray[$i];
        if ($string[0] == $startCharacter) {
            echo $number;
            echo ". ";
            echo $resultArray[$i], "<br>";
            $number += 1;
        }
    }
    return $resultArray;
}
getCoursesByCharacter(file("courses.tsv"), "A");
?>
    </div>
    <div class="section">
        <h2>List of Courses</h2>
<!-- Ex. 4: List of Courses & Ex 6: Query Parameters -->
        <?php 
function getCoursesByOrder($listOfCourses, $orderby)
{
    $resultArray = array();
    foreach ($listOfCourses as $word) {
        $resultArray[] = $word;
    }
    if ($orderby > 0) {
        echo "All of courses ordered by <strong>alphabetical reverse order</strong> are followings : <br><br>";
        rsort($resultArray);
Пример #6
0
        if ($sub == $startCharacter) {
            array_push($resultArray, $listOfCourses[$i]);
        }
    }
    return $resultArray;
}
?>
        <p>
            Courses that started by <strong>'<?php 
echo $startCharacter;
?>
'</strong> are followings :
        </p>
        <ol>
            <?php 
$searchedCourses = getCoursesByCharacter($filename, $startCharacter);
foreach ($searchedCourses as $getCourse) {
    $getCourse2 = explode("\t", $getCourse);
    $getCourse3 = implode("-", $getCourse2);
    ?>
                    <li> <?php 
    echo $getCourse3;
    ?>
</li>
            <?php 
}
?>
        </ol>
    </div>
    <div class="section">
        <h2>List of Courses</h2>
        <?php 
        }
    }
    return $resultArray;
}
?>

        <p>
            Courses that started by <strong>'<?php 
echo $startCharacter;
?>
'</strong> are followings :
        </p>
        <ol>
            <?php 
getCoursesByCharacter($newArr, $startCharacter);
?>
        </ol>
    </div>
    <div class="section">
        <h2>List of Courses</h2>
<!-- Ex. 4: List of Courses & Ex 6: Query Parameters -->
        <?php 
$orderby = 0;
if (isset($_GET["orderby"]) && $_GET["orderby"] == '1') {
    $orderby = 1;
    if ($_GET["orderby"] == "") {
        $orderby = 0;
    }
} else {
    $orderby = 0;
Пример #8
0
        if ($searchedCourses[0] == $startCharacter) {
            $resultArray[] = $searchedCourses;
        }
    }
    return $resultArray;
}
?>
        <p>
            Courses that started by <strong>'<?php 
echo $startCharacter;
?>
'</strong> are followings :
        </p>
        <ol>
            <?php 
$array = getCoursesByCharacter($listOfCourses, $startCharacter);
foreach ($array as $result) {
    ?>
            <li><?php 
    echo $result;
    ?>
</li>
            <?php 
}
?>
        </ol>
    </div>
    <div class="section">
        <h2>List of Courses</h2>
<!-- Ex. 4: List of Courses & Ex 6: Query Parameters -->
        <?php 
Пример #9
0
        <?php 
$startCha = "C";
if (isset($_GET["character"])) {
    $startCha = $_GET["character"];
}
function getCoursesByCharacter($listOfCourses, $startCharacter)
{
    $resultArray = array();
    foreach ($listOfCourses as $listCourses) {
        if ($listCourses[0] == $startCharacter) {
            array_push($resultArray, $listCourses);
        }
    }
    return $resultArray;
}
$searchedCourses = getCoursesByCharacter($lines, $startCha);
?>
        <p>
            Courses that started by <strong>'<?php 
echo $startCha;
?>
'</strong> are followings :
        </p>
        <ol>
            <?php 
foreach ($searchedCourses as $searchCourses) {
    $tmp3 = explode("\t", $searchCourses);
    $tmp4 = implode(" - ", $tmp3);
    ?>
					<li><?php 
    echo $tmp4;