青岛澄润国际贸易有限公司

现在的位置: 主页 > 商讯 > 文章列表

文章正文

PHP无限极分类之数组

作者:青岛澄润国际贸易有限公司 来源:wwww.usabcc.com 发布时间:2017-09-07 12:39:54
PHP无限极分类之数组 <?php $data = array( 1 => array('id' => 1,'name' => 'name1','pid' => 0), 2 => array('id' => 2,'name' => 'name2','pid' => 0), 3 => array('id' => 3,'name' => 'name3','pid' => 1), 4 => array('id' => 4,'name' => 'name4','pid' => 0), 5 => array('id' => 5,'name' => 'name5','pid' => 3), 6 => array('id' => 6,'name' => 'name6','pid' => 3), ); $str = getTree(0); $str = "<select name='term'>" . $str . "</select>"; echo $str; function getTree($id,$spac=0) { $data = array( 1 => array('id' => 1,'name' => 'name1','pid' => 0), 2 => array('id' => 2,'name' => 'name2','pid' => 0), 3 => array('id' => 3,'name' => 'name3','pid' => 1), 4 => array('id' => 4,'name' => 'name4','pid' => 0), 5 => array('id' => 5,'name' => 'name5','pid' => 3), 6 => array('id' => 6,'name' => 'name6','pid' => 3), ); $spac = $spac + 2; static $str; foreach ($data as $k => $v) { if ($v['pid'] == $id) $arr[] = $v; $str .= "<option value='" . $v['id'] . "'>" . str_repeat("&nbsp;",$spac) . " } return $str; } ?>

PHP无限极分类之数组

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:武汉网站推广 https://www.feimao666.com

COPYRIGHT © 2015 青岛澄润国际贸易有限公司 ALL RIGHTS RESERVED.

网站地图 技术支持:肥猫科技
精彩专题:网站建设
购买本站友情链接、项目合作请联系客服QQ:2500-38-100