How do I get the current, item being dealt with while in a foreach loop or... any other type loop... for instance, in perl...
foreach (@array) { print $_; }
or...
print $_ foreach(@array);
IS there something like that in php?
for ($i=0; $i < sizeof($array); $i++) { echo $array[$i]; }
have a look at next(), pos() and current(), too further details > php.net docs
foreach($items as $item) { echo $item; }
and if you want the key
foreach($array as $key => $value) { echo "The key is " . $key . " and the value is " . $value . "<br>"; }
More on it here
Cgraz
thats not what I was looking for, and that was a very simplistic script I gave.. there would be other reasons for the $_ nevermind though 🙁