Home  >  Article  >  Backend Development  >  Traversal method of multi-dimensional array in thinkPHP

Traversal method of multi-dimensional array in thinkPHP

WBOY
WBOYOriginal
2016-07-29 09:07:111188browse

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>
   <input type="checkbox" name="{$k}" value="1">{$k}
  </label>
   <foreach name="vo" item="drug">
   <label>
    <input type="checkbox" name="{$drug.en_name}" value="1">{$drug.ch_name}
   </label>
   </foreach>
</foreach>

For more related content about thinkPHP, you can check out the special topics on this site: "Introduction to ThinkPHP Tutorial" and "Summary of Common Methods of ThinkPHP"

I hope that what this article describes will be helpful to everyone PHP programming based on the thinkPHP framework helps.

The above introduces the traversal method of multi-dimensional arrays in thinkPHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn