associative array to list

associative array to list

am 15.09.2007 21:32:33 von lskatz

Hi,
I want to make an associative array become a list, and hopefully an
html list (

Re: associative array to list

am 15.09.2007 21:45:12 von lskatz

Ah, nevermind, I realized I was adding onto my output variable twice.
Here's the fixed up function

function formatDocumentation($ToC,$level=0){
if($level==0) $output="";
$numMenus=count($ToC);
$name=array_keys($ToC);
$indentation=stringMultiply(" ",$level);

foreach($ToC as $thisName => $content) {
$output.= "$indentation$thisName\n";
if(is_array($content)){
$output.= formatDocumentation($content,$level+1);
}
else{
$output.= "$indentation$content\n\n";
}
}
return $output;
}

Re: associative array to list

am 15.10.2007 14:11:52 von Hans-Peter Sauer

"lskatz" wrote in message
news:1189885512.959260.307230@19g2000hsx.googlegroups.com...
> Ah, nevermind, I realized I was adding onto my output variable twice.
> Here's the fixed up function
>
> function formatDocumentation($ToC,$level=0){
> if($level==0) $output="";
> $numMenus=count($ToC);
> $name=array_keys($ToC);
> $indentation=stringMultiply(" ",$level);
>
> foreach($ToC as $thisName => $content) {
> $output.= "$indentation$thisName\n";
> if(is_array($content)){
> $output.= formatDocumentation($content,$level+1);
> }
> else{
> $output.= "$indentation$content\n\n";
> }
> }
> return $output;
> }



:)
Mike



--------------------------------------------------
http://www.documentscanningbureau.com