PDA

View Full Version : foreach() help


Adrian Schneider
03-06-2005, 05:02 AM
:disappointed:

I need help getting my foreach statement to work proplerly. This is as close as I could get, $playername displays properly, but $id just displays Array.


foreach ($batsmenarray as $id)
{
foreach ($id as $playername => $playername)
{
eval('$fantasy_cricket_batsmenbit .= "' . fetch_template('fantasy_cricket_batsmenbit') . '";');
}
}

Each value of $batsmenarray is set up like: something[$id][$playername]. I tried following the one of php.net, but it won't work for me for some reason. Any help would be greatly appreciated.

Dean C
03-06-2005, 09:29 AM
Before that code place:


echo '<pre>';
print_r($batsmenarray);
echo '</pre>';


And paste the output for us :) Also what is the exact error you get.

Marco van Herwaarden
03-06-2005, 11:59 AM
foreach ($id as $playername => $playername)

shouldn't that be something like:
foreach ($id as $playername => $playerdata)

(anyway not 2 times playername)