The example in this article describes the traversal method of multi-dimensional arrays in thinkPHP. Share it with everyone for your reference, the details are as follows:
$drug=array( 'ACEI'=>array(array('ch_name'=>'帮客之家','en_name'=>'captopril'),array('ch_name'=>'脚本下载','en_name'=>'enalapril'), array('ch_name'=>'赖诺普利','en_name'=>'lisinopril')), 'ARB'=>array(array('ch_name'=>'脚本源码','en_name'=>'eprosartan'), array('ch_name'=>'jb51','en_name'=>'candesartan'), array('ch_name'=>'PHP学习','en_name'=>'losartan'),array('ch_name'=>'JS学习','en_name'=>'valsartan'), array('ch_name'=>'脚本教程','en_name'=>'irbesartan')), );
<foreach name="drugs" item="vo" key="k"> <label class="checkbox"> <input type="checkbox" name="{$k}" value="1">{$k} </label> <foreach name="vo" item="drug"> <label class="checkbox inline drug"> <input type="checkbox" name="{$drug.en_name}" value="1">{$drug.ch_name} </label> </foreach> </foreach>
For more information related to thinkPHP, please view the special topics on this site: "Introduction to ThinkPHP Tutorial" and "Summary of Common Methods of ThinkPHP"
I hope this article will be helpful to everyone’s PHP programming based on the thinkPHP framework.