return $finalDisplay;
}
$finalDisplay2 = getFinalData('red', $json);
if ($dayOfWeek == 0 || $dayOfWeek == 6) {
    if ($dayOfWeek == "6") {
        $serviceStr = 'SAT';
    }
    if ($dayOfWeek === "0") {
        $serviceStr = 'SUN';
    }
    $finalDisplay = array();
    $finalDisplay3 = array();
} else {
    $finalDisplay = getFinalData('gray', $json);
    //$finalDisplay2 = getFinalData('red', $json);
    $finalDisplay3 = getFinalData('green', $json);
}
/*
    [4111538] => Madison St. & 8th St.
    [4111546] => Hudson St. & Newark St.
    [4132090] => Howe Center
    [4132098] => 11th St. & Park Ave.
    [4132102] => Madison St. & 4th St.
    [4141098] => River St. & 4th St.
    [4141102] => 12th St. & Grand St.
    [4151394] => Jackson St. betw. 6th St. & 7th St.
    [4151398] => Madison St. & 11th St.
    [4162754] => Marshall St. & 2nd St.
    [4162762] => 11th St. & Hudson St.
    [4176262] => Madison St. & 7th St.
    [4176264] => 1st St & Harrison St.
Example #2
0
    if (!$tableNameFromQuery && !$sort && !$limit) {
        $data = getAllDataFromDatabase($tableNamesArray, $con);
    } else {
        if (!$tableNameFromQuery) {
            $data = getDataFromAllTableBasedQuery($tableNamesArray, $sort, $order, $limit, $con);
        } else {
            mysqli_query($con, "SET CHARACTER SET utf8");
            $query = "SELECT * FROM " . $tableNameFromQuery . " " . ($sort ? " ORDER BY " . $sort . ($order ? " " . strtoupper($order) : " ASC") : "") . " " . ($limit ? "LIMIT " . $limit : "");
            $result = mysqli_query($con, $query);
            if (!$result) {
                echo "Something wrong in your query.</br>" . $query;
                die;
            }
            $data[$tableNameFromQuery] = array();
            while ($row = mysqli_fetch_assoc($result)) {
                array_push($data[$tableNameFromQuery], $row);
            }
        }
    }
    return $data;
}
// getting all the table names
$tableNamesArray = getTableNamesFromDatabse($databaseName, $con);
$tableNameFromQuery = isset($_REQUEST['table']) && trim($_REQUEST['table']) ? $_REQUEST['table'] : "";
$sort = isset($_REQUEST['sort']) && trim($_REQUEST['sort']) ? $_REQUEST['sort'] : "";
$order = isset($_REQUEST['order']) && trim($_REQUEST['order']) ? $_REQUEST['order'] : "";
$limit = intval(isset($_REQUEST['limit']) && trim($_REQUEST['limit']) ? $_REQUEST['limit'] : 0);
$finalData = getFinalData($tableNamesArray, $tableNameFromQuery, $sort, $order, $limit, $con);
echo json_encode($finalData);
mysqli_close($con);
die;