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('http://development.irish-surge-forecast.ie/wp/Test_directory/Date.csv'));

echo '<pre>';
print_r($csv);
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


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: