Jump to content

Displaying a files contents - with formatting


sh0wtym3

Recommended Posts

I'm using the code below to read, and display a files contents:

        $filename = "style.css";
$handle = fopen($filename, "r+");
// Read the file, and store contents in a variable
$content = fread($handle, filesize($filename));
// Close the connection
fclose($handle);
        // Echo the contents
        echo "$content";

 

However when echoing the contents (its a CSS file), it "squishes" everything together, making it extremely difficult to read.

 

Whereas in the actual style.css file theres formatting (like spaces between each line of CSS) making it easier to read.

 

How do I preserve this formatting?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.