The use of nested volist tags in thinkphp enables the output of multidimensional arrays. Volist nested using a normal two-dimensional array, you can use the Volist label directly loop output. For multidimensional arrays, you need to use the volist tag again to nest the loop output for the array members. Build a multidimensional array: $food = Array (), $food [0][' Fruits '][0][' fruits1 '] = ' Apple 1 '; $food [0][' Fruits '][0][' fruits2 '] = ' orange 1 '; $food [0][ ' Fruits '][0][' fruits3 '] = ' banana 1 '; $food [0][' vegetables '] = ' cabbage 1 '; $food [1][' Fruits '][1][' fruits1 '] = ' Apple 2 '; $food [1][' Fruits '][1][' fruits2 '] = ' orange 2 '; $food [1][' Fruits '][1][' fruits3 '] = ' banana 2 '; $food [1][' vegetables '] = ' cabbage 2 '; use Print_r () The function prints the array as follows: Array ([0] = = Array ([fruits] = = Array ([0] => ; Array ([fruits1] + apple 1 [fruits2] + Orange Sub 1 [fruits3] + banana 1)) [Vegetables] = Cabbage 1) [1] = = Array ([fruits] = = Array ([1] = ARR Ay ( [Fruits1] + apple 2 [fruits2] = orange 2 [fruits3] + bananas 2 )) [vegetables] + cabbage 2) Assign the variable to the template in the corresponding module operation (e.g. Index/display) and output the template: $this->assign ("Food", $food); $this->display (); template tpl/default/index/display.html:<p> variety:</p> <BR/><volist name= "food" id= "vo" > <volist name= "vo[' fruits ']" id= "F" > <p> fruit 1:{$f [' Fruits1 ']} </p> <p> Fruit 2:{$f [' fruits2 ']}</p> <p> fruit 3:{$f [' fruits3 ']}</p> </volist> <p> Vegetables: {$vo [' vegetables ']}</p><br/></volist> in the template, first the $food variables are looped out. Because the member fruits of the $food array is also an array, the $VO [' fruits '] variable is recycled (note that there is no $ symbol). The output is as follows: Food variety: Fruit 1: Apple 1 fruit 2: Orange 1 Fruit 3: Banana 1 Vegetable: Cabbage 1 fruit 1: Apple 2 fruit 2: Orange 2 Fruit 3: Banana 2 vegetable: Cabbage 2 Similarly, this method allows you to loop through the array of more dimensions.
thinkphp template volist label nested loop output multidimensional array