我有以下数组
Array
(
[Visitors Promotion in General] => Array
(
[Digital] => Array
(
[Mobile Apps] => Array
(
)
[Web Apps] => Array
(
)
)
[Mass Media] => Array
(
[Print Media] => Array
(
[Mass] => Array
(
)
)
)
)
[Direct to Exhibitors] => Array
(
[EDM] => Array
(
)
[IMTEX Website] => Array
(
)
)
)
我想使用jQuery将其显示为列表。数组大小是动态的
Visitors Promotion in General
Digital
Mobile Apps
Web Apps
Mass Media
Print Media
Mass
Direct to Exhibitors
EDM
IMTEX Website
答案 0 :(得分:0)
你可以尝试使用PHP。
<?php
$arr = array(
'Visitors Promotion in General' => array(
'Digital' => array(
'Mobile Apps' => array(
),
'Web Apps' => array(
)
),
'Mass Media' => array(
'Print Media' => array(
'Mass' => array(
)
)
)
),
'Direct to Exhibitors' => array(
'EDM' => array(
),
'IMTEX Website' => array(
),
)
);
echo "<ul>";
foreach ($arr as $key => $value) {
if (is_array($value)) {
echo "<li>".$key."</li>";
foreach ($value as $key1 => $value1) {
if (is_array($value)) {
echo "<ul>";
echo "<li>".$key1."</li>";
foreach ($value1 as $key2 => $value2) {
echo "<ul>";
echo "<li>".$key2."</li>";
foreach ($value2 as $key3 => $value2) {
echo "<ul>";
echo "<li>".$key3."</li>";
echo "</ul>";
}
echo "</ul>";
}
echo "</ul>";
}
}
}
}
echo "</ul>";
?>