tags:

views:

61

answers:

2

I have the following code:

    var_dump($cumulitive);
    $y_axis_max = max($cumulitive)*1.3;
    var_dump($y_axis_max);

It outputs the following:

array(16) {
  [0]=>
  int(0)
  [1]=>
  int(0)
  [2]=>
  int(0)
  [3]=>
  int(0)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(0)
  [7]=>
  int(0)
  [8]=>
  int(0)
  [9]=>
  int(0)
  [10]=>
  int(0)
  [11]=>
  int(4)
  [12]=>
  int(4)
  [13]=>
  int(4)
  [14]=>
  int(9)
  [15]=>
  int(9)
}
float(NAN)

As you can see, $y_axis_max is giving NAN. So I try this: I restart WampServer. It works now. I refresh the browser. Works again. refresh the browser again. Now it doesn't work, and I can't get it to work again without restarting Apache. From the 3rd request on it stops working.

It USED to work just fine. Then I changed some things. Specifically, I modified my app to use the DateTime class in a few places. But that shouldn't make this strange error occur. Any ideas on how to debug this?

If I call the $y_axis_max = .. line of code twice in a row, then I get this for $y_axis_max:

float(@.7)

What the heck is that?

EDIT: Seems that calling DateTime::diff earlier causes the error. Any workaround ideas?

+1  A: 

max() will work on arrays. Looks like you have some form of corruption in your code. If one of the elements in the array is a NAN you will get this result. Try testing a smaller script on your server in order to isolate the problem.

fmk_ca
Seems that calling DateTime::diff earlier causes the error. VERY STRANGE
Jonah
A: 

Seems that calling DateTime::diff earlier causes the error. I just used a work-around so not to use it.

Jonah