<?php

// CATE SONGS LIST FILENAME: CATESONGS.TXT

$file = "./list/all/catesongs.txt";

    // Check if the file exists and is readable
    if (file_exists($file) && is_readable($file)) {
        // Open the file for reading
        $handle = fopen($file, "r");
    
        // Loop through each line until the end of the file
        while (($line = fgets($handle)) !== false) {
            // Print each line

            $linetext = ucwords($line);

            $linelink = strtolower($line);
            $linelink = rtrim($linelink);
    
            $linelink= str_replace(' ', '-', $linelink);
    
            echo "<div class='links'>
            <h3> Trending Songs</h3>
            <ul>
            <li><a href='/mp3-songs/$linelink' class='footer1v' >$linetext</a></li>
            </ul>
            </div>
    ";
        }
    
        // Close the file handle
        fclose($handle);
    } else {
        // If file doesn't exist or is not readable, print an error message
        echo "Error: The file does not exist or is not readable.";
    }
    ?>