Forum Moderators: coopster
$image = explode(", ", $row[image]);
So I get this:
Array ( [0] => foo.jpg )
But when I do this:
foreach ($image as $v)
{
echo $v;
}
The value of $v is also an array.
Doing a print_r on $v gives me:
Array ( [0] => foo.jpg [1] => 0 )
when it should just be foo.jpg.
What's going on here?
I've had similar problems in previous versions of PHP, in my case always brought on by either incorrect or overly aggressive use of aliasing elsewhere in the code. The interpreter seems to get kicked into wacky mode and things break all over.
echo '<pre>image is
';
var_dump($image);
foreach ($image as $k => $v){
echo '
key is '.$k. and v is '.var_dump($v);
}
echo '</pre>';
var_dump()gives you a little more info than print_r (its format is just more irritating), but on the off chance its output could be revealing, it's probably worth a try. Sure hope there isn't a problem with the new foreach. Jolly, what kind of 'aggressive aliasing' or what was that do you mean, what was it for you that broke foreach?
Typically when I've messed this up it takes quite a bit of debugging, as symptoms manifest far from the cause. I've definitely seen symptoms where what goes in isn't what comes out, like in the foreach problem we're talking about here.
Vince