I have simple function but got the error message : Notice: Undefined offset: 3 in
i checked the problem is in line : $newValue += $value[$i];
the answer of below function is "6" but error message still displayed.
<?php
function countMe($value) {
$newValue = 0;
for ($i=0; $i<=count($value); $i++)
{
$newValue += $value[$i];
}
return $newValue;
}
$value[0] = 1;
$value[1] = 2;
$value[2] = 3;
echo countMe($value);
?>
I know the solution is just Suppress the error with the @ operator such as @countMe($value) but i want to know What's wrong with this function ?? Any help would be appreciated. Thanks