So, I started using Zend Studio and it gives me warnings on my foreach loops when I only need to use the $key and not the $value.
In other words:
foreach($array as $key => $value)
{
do_something_with($key);
}
The above will throw a warning because I am not using $value.
I lived with the warnings for a while, until I decided to try this.
foreach($array as $key => $key)
{
do_something_with($key);
}
This seems to work and puts the "key information" in the $key variable (just fine). Also Zend doesn't throw the warning anymore (YEAH). Anyways my question is:
Does anyone know any sort of problems which will arise from doing this?
I have never tried it before and I haven't found any sort of information on doing this. I am using "PHP Version 5.2.4-2ubuntu5.4" and I am specifically interested if this causes errors (or perhaps puts the "value information" in the $key variable) in other versions of PHP such as 4 or 6.
Thanks for any help you can give.