I have a problem with PHP code : I have been using PHP to generate static HTML files (via fopen/fwrite) depending on some SQL requests (among others) and I have a problem with a foreach loop:
$maincats = array('/boutique' => 'TOUS LES OBJETS',
'/boutique/nouveautes' => 'NOUVEATES',
'/boutique/luminaires' => 'LUMINAIRES',
'/boutique/assises' => 'ASSISES',
'/boutique/rangements' => 'RANGEMENT',
'/boutique/objets-deco' => 'OBJETS DECO',
'/boutique/tables' => 'TABLES',
'/boutique/art-de-la-table' => 'ARTS DE LA TABLE',
'/boutique/high-tech' => 'HIGH-TECH',
'/boutique/enfants' => 'ENFANT');
$page .= '
<div id="menuWrap">
<div id="menu">
<ul>';
$i = 0;
foreach ($maincats as $url => $name);
{
$i++;
$page .= '
<li><a ';
$page .= 'href="'.$url.'">'.$name.'</a></li>';
}
I tried print_r before the foreach, I can see ALL the elements of the array (it works just fine). But every time I execute this the $page only contains ONE <li> , the last item of the array, and $i = 1. I can’t think of what I am doing wrong.
Anyone has an idea where that comes from?
Remove ; from