Home >Backend Development >PHP Tutorial >PHP嵌套循环输出导航[不使用递归]

PHP嵌套循环输出导航[不使用递归]

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:34:371161browse

<?php// 本类由系统自动生成,仅供测试用途class TestAction extends Action {    public function index(){	$select=M('select');		$rs=$select->where('parent_id=0')->select();		//$rs=$select->where('parent_id='.$parentid)->select();		for($i=0;$i<count($rs);$i++){			if($i==0){				echo '<p class="letter" id="'.$rs[$i]['index'].'">'.$rs[$i]['index'].'</p>';				$index=$rs[$i]['index'];			}			//去重输出首字母			if($rs[$i]['index']!=$index){				echo '<p class="letter" id="'.$rs[$i]['index'].'">'.$rs[$i]['index'].'</p>';				$index=$rs[$i]['index'];			}			echo $rs[$i]['name'].'<br>';			$series=$select->where('parent_id='.$rs[$i]['id'])->select();			for($j=0;$j<count($series);$j++){				echo $series[$j]['name'].'<br>';				$model=$select->where('parent_id='.$series[$i]['id'])->select();				for($x=0;$x<count($model);$x++){					echo $model[$x]['name'].'<br>';				}				//for()			}		}    }}


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