How PHP loops the contents of an array into a "link" + "Dropdown selection" style

Source: Internet
Author: User
How PHP loops the contents of an array into a "link" + "Dropdown selection" style
Write Yourself a loop:
PHP Code
  
   
  
   


The result of the above loop is:
HTML Code
  
   Youku  Tudou  Sina


How do I loop it into the following style:
HTML Code
  
             Youku      First episode      Second episode      Third episode           Potatoes           Sina       First episode      Second episode      Third episode      


------Solution--------------------
PHP Code
$videolist = "Youku {span}youku{span} address 1{SL} address 2{SL} address 3{li} potato {Span}tudou{span} potato address {Li} sina {span}sina{span} sina address 1{SL} Sina address 2{SL} sina address 3{li} "; $ar =preg_split ('/\{li\}/', $videolist, -1,preg_split_no_empty);     $html = "; $j =array (0=> ' first episode ',1=> ' second episode ',2=> ' third episode '); foreach ($ar as $v) {$arr =preg_split ('/\{.*?\}/', $v); if (count ($arr) >3) {$html. = ''."          \ n "; $html. = ''. $arr [0]. ''."                  \ n "; foreach (Array_slice ($arr, 2) as $kl = + $VL) $html. = ''. $j [$kl]. ''."              \ n "; } else{$html. = '. $arr [0]. "."     \ n "; }}echo $html;------Solution--------------------Can't sleep, give you a change, not not, I guess you are too lazy ...Replace {SL} in the array with {span}, or sub-stringPHP Code
   
   ";}? >
Related Article

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.