$input
is an array with some values, and I am sure the key from the bellow code example exists. $points
is an array of strings.
I am simply getting Undefined index:
(with no other information) for this code:
foreach ($points as $point) {
$point_value = $input[$point];
...
but if I dump it:
foreach ($points as $point) {
die(var_dump($input[$point]));
...
then I get the value correctly, without having Undefined index
reported.
Now, I am using
$point_value = isset($input[ $point ]) ? $input[ $point ] : '';
and it works fine. But I was wondering why does that happen? Why is the index not being initialized in the first case, but it is being initialized when I simply dump the value?
I read around about this "problem", but could not really grasp the idea behind it. Could I get some simpler explanation, please?