How does PHP loop the array content into a loop written by itself in the "link" + "drop-down selection" style: PHPcode & lt ;? Php $ videolist = & quot; youku {span} address 1 {sl} address 2 {sl} address 3 {li} {span} tudou {span} PHP how to loop the array content "link" + "drop-down select" style
A self-written loop:
PHP code
The result of the above loop is:
HTML code
Youku Tudou Sina
How to cycle to the following style:
HTML code
Youku Episode 1 Second Set Episode 3 Tudou Sina Episode 1 Second Set Episode 3
------ Solution --------------------
PHP code
$ Videolist = "youku {span} address 1 {sl} address 2 {sl} address 3 {li} tudou {span} potato address {li} 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 set', 1 => 'second set', 2 => 'third set'); 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 --------------------You can't sleep. change one for you. no, no. it's estimated that you are too lazy ..........Replace {sl} in the array with {span}, or use substrings.PHP code
";}?>