Read CSV in WordPress using PHP

I am in the process of setting up a wordpress site to display a series of daily forecast plots. These plots are created by dygraps are updated everyday when I replace CSV files.

However on my WordPress page I want to have one line of text informing the reader when the posts were last updated. To do this I created an additional CSV file that was then uploaded to a directory. This 1 line file called “date.csv” looks like this:

Forecast updated,18/05/2018

I am trying to use php to read this csv and the print this line on a wordpress page by using the following:

$csv = str_getcsv(file_get_contents(''));

echo '<pre>';
echo '</pre>';

However the output on the wordpress page looks like this:

Array (
[0] => )

Any ideas? Im not a PHP expert by any stretch, but would appreciate any feedback.

Read more here: Read CSV in WordPress using PHP

Leave a Reply

Your email address will not be published. Required fields are marked *