dreamworms wrote:
> I wanna have nested repeat region in repeated region.
I'm not saying it's necessarily the best way to do it, but
this is
certainly one way. The categories are stored as a
multidimensional,
associative array. Each element needs to be an array, even if
it's
empty. The recursive function displayCats() then loops
through the whole
thing and produces the nested results you seek.
<?php
$cats = array('Top Level 1' => array(
'sub a' => array(), 'sub b' => array(), 'sub c' =>
array()),
'Top Level 2' => array(
'sub d' => array(
'sub sub a' => array(), 'sub sub b' => array()),
'sub e' => array(
'sub sub c' => array(), 'sub sub d' => array()),
'sub f' => array(
'sub sub e' => array(), 'sub sub f' => array(), 'sub
sub g' =>
array())),
'Top Level 3' => array(),
'Top Level 4' => array(),
'Top Level 5' => array());
function displayCats($array) {
echo "<ul>\n";
foreach ($array as $key => $value) {
echo "<li>$key</li>\n";
if ($value) {
displayCats($value);
}
}
echo "</ul>\n";
}
displayCats($cats);
?>
--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/