PHP function that creates a nested ul li?

前端 未结 5 724
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 15:18

I am attemptting to attach a small CMS to a website I am creating. However I have come across a small problem. The CMS uses PHP functions for inserting menus, these PHP func

5条回答
  •  梦谈多话
    2021-01-07 15:43

    It appears Topbit already beat me to this, but mine is slightly differs in that it doesn't echo the value straight to the output stream, but saves it in a variable that you may echo at your convenience:

    \n";
        foreach($arr as $val) {
            if (is_array($val)) {
                $output .= "
  • \n" . GenerateMenu($val, $output) . "
  • \n"; } else { $output .= "
  • " . $val . "
  • \n"; } } $output .= "
\n"; return $output; } $html = GenerateMenu($menu); ?>

Edit:

Thanks Gumbo and Topbit, now that I'm on my machine with PHP installed, I have tested it and it works fine.

提交回复
热议问题