bonjour,
j'ai un petit soucie au niveau d'une boucle récursive.
j'essaye de récupérer une numérotation (pour ma sitemap)
quelqu'un aurait-il une idée où je puisse ajouter les concaténations de mes variables.
je voudrais obtenir une numérotation du type :
1
1.1
1.2
1.2.1
1.2.2
2
3
3.1
3.2
...
voici mon code simplifié
function make_sitemap($array,$level=0,$pos='')
{
$i=1;
if($level==0){
$this->buffer .= "\n".'<ul class="sitemap">'."\n";
}else{
$this->buffer .= "\n".'<ul>'."\n";
}
foreach($array as $element)
{
$this->buffer .= '<li id="item_' . $element['properties']['page_id'] . '" style="padding-left: '.(10*$level).'px;">'.($level != 0 ? '› ' : '.').' <a href="/index.php?page='.$element['properties']['page_id'].'">'.$i.' '.$element['properties']['page_name'].'</a></li>'."\n";
if(isset($element['childs']) and is_array($element['childs']))
{
$this->make_sitemap($element['childs'],($level+1),$pos);
}
$i++;
}
$this->buffer .= '</ul>';
}:
merci d'avance