But there is a problem because my version of dayfile.txt before 01/01/2011 does not have the sunshine hours field.
My modified Javascript version deals with the fact that the early dayfile.txt is shorter than the 2011 file and just leaves blank fields for sunshine in 2010 (see http://poundstockpacket.org.uk/datasummary_gj.html)
However my modified PHP version produces an error of Notice: Undefined offset: 24 when it tries to display 2010 sunshine hrs. I assume that this is because my dayfile.txt in 2010 didn't have field 24, sunshine hours (see http://poundstockpacket.org.uk/datasummary_gj_01.php)
I have got around the problem by hardcoding a trap for the error (see http://poundstockpacket.org.uk/datasummary_gj_02.php) This looks for 2010 and sunshine hours
Code: Select all
// need to trap old 'layouts' that did not contain sunshine data
if( $tableYear == '2010' && $whatdata == 'sunhours')
{$data[$id] = '';}
else
{ $data[$id] = $buf_arr[$dayfilecol]; } - Why does the Javascript version not produce an error?
Is there a better way of dealing with the problem in PHP without hardcoding?
Graham