How does this generate the effect of the drop-down option?

Source: Internet
Author: User

Reply content:


should be their own splicing, probably the following way

  $arr = [0=> [' id ' = ' 1 ', ' title ' = ' Total column ', ' Children ' =>[0=>[' id ' = ' 4 ', ' title '            ' + ' interview ', ' Children ' =>[]], 1=>[' id ' = ' 5 ', ' title ' = ' announcement ', ' children ' =>[]], 1 = [' id ' = ' 3 ', ' title ' = ' Total theme ', ' Children ' =>[0=>[' id ' = ' 6 ', ' title ' + ' Sateri card on it ', ' children ' =>[]], 1=>[' id ' = ', ' title ' = ' Chicken jelly ', ' children ' =>[0=> [' id ' = ' 7 ', ' title ' = ' Love life ', ' children ' =>[]], 1=>[' id ' = ' 8 ', ' title ' = ' Reduced productivity pride ', ' CHI                Ldren ' =>[0=>[' id ' = ' 9 ', ' title ' = ' big ', ' children ' =>[]]    ]                ],            ]            ]];    $returnInfo = Getselectarray ($arr);   Var_dump ($returnInfo);p ublic function Getselectarray ($arr, $grade = 0) {$char = [', ' ├ ', ' |├ ', ' |        ├ '];   $encChar = [' ', ' ┕ ', ' |┕ ', ' |        ┕ ']; $retuRninfo = [];            foreach ($arr as $key = + $val) {$sort = $key + 1;            $tmp [' id '] = $val [' id '];            if ($val = = End ($arr)) {$tmp [' title '] = $encChar [$grade]. $val [' title '];            } else {$tmp [' title '] = $char [$grade]. $val [' title '];            } $children = Getselectarray ($val [' Children '], $grade + 1);            $returnInfo [] = $tmp;        $returnInfo = Array_merge ($returnInfo, $children);    } return $returnInfo; }
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.