I have an array that stores numeric values. The issue is when I want to store the value 0:
....
$gradePoints = 0;
$students[$var1][$var2] = $gradePoints;
....
To check the value has been stored:
echo $students[$var1][$var2];
returns 0 ... so the value 0 has been successfully stored in the array.
However later when I search the array:
$value= isset($students[$var1][$var2]) ? $students[$var1][$var2] : '';
if ($value <> '')
{
do something;
}
If $value
is anything but 0 it is fine but php
seems to overlook the value 0. If I change
$gradePoints = 0;
to
$gradePoints = 0.1;
all is well. Can anyone explain why $value <> ''
works for all values other than 0?