Ejemplo n.º 1
0
<?php

if (isset($_GET["type"])) {
    $type = $_GET["type"];
    if ($type != "list") {
        header("HTTP/1.1 400 Invalid Request");
        die("HTTP/1.1 400 Invalid Request - you passed in a wrong type parameter.");
    }
    nameList();
} else {
    ranks();
}
function nameList()
{
    $names_array = array();
    // read 'ranks.txt' file line by line, extract all the names, and fill the '$names_array' with the extracted names
    // 'ranks.txt' file을 한줄 한줄 읽고, 모든 이름을 추출하여, 추출한 이름들로 '$names_array'를 채우시오
    $names_array = array();
    $rankstxt = file("ranks.txt");
    foreach ($rankstxt as $line) {
        array_push($names_array, explode(" ", $line)[0]);
    }
    if ($names_array) {
        // produce and emit all the names extracted from the 'ranks.txt' as an output in JSON data format
        // 'ranks.txt'에서 추출한 모든 이름들을 JSON 데이터 형식으로 만들어 내보내시오
        $jsonArray = array();
        header("Content-type: application/json");
        for ($i = 0; $i < sizeof($names_array); $i++) {
            $jsonArray["{$i}"] = $names_array[$i];
        }
        print json_encode($jsonArray);
Ejemplo n.º 2
0
            if (get_terms_meta($catID, 'staff', true)) {
                $showStaff = explodedCat($catID, staff);
                $showHosts = array_merge($showHosts, $showStaff);
            }
            unset($episodeHosts);
            unset($diff);
            $episodeHosts = [];
            $coAuthors = get_coauthors();
            foreach ($coAuthors as $coAuthor) {
                $episodeHosts[] = get_the_author_meta('id', $coAuthor->ID);
            }
            $diff = array_diff($episodeHosts, $showHosts);
            if ($diff) {
                unset($epGuests);
                $epGuests = [];
                $epGuests = nameList($diff);
                echo '(feat. ' . andList($epGuests), ')</i>';
            }
        }
        ?>
                                    </li>

                                    <?php 
    }
    /* Ends while have posts */
    ?>
                                </ul>
                            </div>
                            <?php 
} else {
    ?>