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

Traversal method of multi-dimensional array in thinkPHP

WBOY
Release: 2016-07-29 09:07:11
Original
1197 people have browsed it

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')),
);

Copy after login

<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>

Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template