HELP!
I have been trying variations of the code posted below with little success. The log()
function generates a -INF statement when trying to calculate the log of zero or the
log of an empty value in the associative array. With the "IF then unset() "
statements in place, the total contents of log_high[] and log_low[] arrays become
empty. Without the "IF then unset()" statements the arrays are full but the program
times out because it can't use INF in imageline(). I've gone through various rewrites
on this code block but have come up with nothing that works, and I need professional
help (but that's a different story).
Thanks,
hugh
Failing code:
for ($year=($current_year-5);$year<=($current_year+1);$year++)
{
$x_distance=20+($year-($current_year-9))*20;
$high_distance=420-round(log($high[$year])*75,0);
$low_distance=420-round(log($low[$year])*75,0);
if ($high_distance=="INF") / / INF is a double
{
unset($high_distance);
}
if ($low_distance=="INF")
{
unset($high_distance);
}
if (isset($high_distance) and isset($low_distance))
{
imagettftext($image,5,0,($x_distance),($high_distance),$black,$font2,"n");
imagettftext($image,5,0,($x_distance),($low_distance),$black,$font2,"n");
imageline($image,$x_distance),$high_distance,($x_distance),$low_distance,$red);
}
$log_high[$year]=$high_distance;
$log_low[$year]=$low_distance;
}