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
";}? >