Topic: A simple question on php arrays and the foreach loop
I have a webpage of links that i want displayed under different headings, depending on which array they're in. I have 4 different arrays...
I had identical code for all of these so i thought i would write a function....
This is what I came up with:
function listlinks ($array)
{
$counter = '1';
foreach ($array as $key => $value)
{
if($counter%2){ echo '<tr class="alt"><td>'; }else{ echo '<tr><td>'; }
echo " » $value</a></td></tr>";
$counter++;
}
}
It keeps telling me that I have an invalid arguement supplied for foreach.
Can anyone help?