Hello, I have a multidimensional array i like to make every category to be clickable and to show its own sub-categories i have something like this... pls help to achieve this.
function makeList(array $Array) {
$Output = '<ul>';
foreach($Array as $Key => $Value) {
$Output .= "<li><input type='submit' name='value[$Key]' value='$Key' />";
if(is_array($Value)) {
$Output .= makeList($Value);
} else {
$Output .= "<a name='$Value' href='#'>".$Value."</a>";
}
$Output .= '</li>';
}
$Output .= '</ul>';
return $Output;
}
$categories = array(
'cars' => array(
'BMW' => array(
'X1',
'X3',
'X5',
'X6'
),
'AUDI' => array(
'A3',
'A6'
),
'MERCEDES' => array(
'A Class' => array('Sedan', 'Coupe', 'Sport'),
'B Class'
)
),
'moto' => array(
'SUZUKI',
'HONDA',
'YAMAHA'
),
'phones' => array(
'SAMSUNG',
'LG',
'MOTOROLA'
)
);
echo makeList($categories);