代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网后台管理系统</title> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="format-detection" content="telephone=no"> <link rel="stylesheet" href="static/css/style.css?ddd" media="all"> <link rel="stylesheet" href="static/css/jquery.dad.css?ddd" media="all"> <link rel="stylesheet" href="static/css/home.css?ddd" media="all"> <script src="static/js/jquery-1.11.3.min.js"></script> <script src="static/js/jquery.dad.min.js"></script> </head> <body> <?php include "form.php"; ?> <div class="home-top phpcn-clear"> <ul class='phpcn-col-md10'> <?php foreach($nav as $val){ if(is_array($val)){ ?> <li> <a href=""><?php echo $val[0]; ?> <i class="phpcn-icon phpcn-icon-down"></i></a> </li> <?php }else{ ?> <li> <a href=""><?php echo $val; ?></a> </li> <?php } } ?> </ul> <dl class='phpcn-col-md2'> <dd> <a href="">免费注册</a> </dd> <dd> <a href=""><i class="phpcn-icon phpcn-icon-huiyuan2"></i>登陆</a> </dd> </dl> </div> <!--头部结束---> <!--LOGO与搜索---> <div class="phpcn-main phpcn-mt-60"> <div class="logo-top phpcn-clear"> <div class="phpcn-col-md4"> <a href=""> <img src="<?php echo $logo['src']; ?>"> </a> </div> <div class="phpcn-col-md4"> <input type="" name=""> <i class="phpcn-icon phpcn-icon-jinduchaxun"></i> </div> <div class="phpcn-col-md4"> <dl class="erwei-code"> <dd> <a href=""><i class="phpcn-icon phpcn-icon-huiyuan1"></i></a> </dd> <dd> <a href=""><i class="phpcn-icon phpcn-icon-danmu1"></i></a> </dd> <dd> <a href=""><i class="phpcn-icon phpcn-icon-duoxuankuang1"></i></a> </dd> <dd> <a href=""><i class="phpcn-icon phpcn-icon-jishufuwu"></i></a> </dd> <dd> <a href=""><i class="phpcn-icon phpcn-icon-peiwangyindao"></i></a> </dd> <dd> <a href=""><i class="phpcn-icon phpcn-icon-wenjianjia"></i></a> </dd> <dd> <a href=""><i class="phpcn-icon phpcn-icon-huiyuan1"></i></a> </dd> </dl> </div> </div> <!--LOGO与搜索结束---> <!--菜单 开始 ---> <div class="menu phpcn-mt-30 phpcn-clear"> <div > <?php foreach ($caidan as $val){ ?> <dl class="<?php echo $val['classa']; ?>"> <dt> <i class="phpcn-icon <?php echo $val['classb'] ?>"></i> <span><?php echo $val['title']; ?></span> </dt> <dd> <?php foreach($val['cai'] as $xiaocai){ ?> <a href=""><?php echo $xiaocai ?></a> <?php } ?> </dd> </dl> <?php } ?> </div> </div> <!--菜单 结束---> <!--幻灯片--> <div class="phpcn-clear banner phpcn-mt-30 "> <div class="phpcn-col-md9 " > <div class="pi"> <div class="pike"> <?php foreach($banner as $val){ ?> <div> <img src="<?php echo $val['src']; ?>" alt="<?php echo $val['alt']; ?>"> </div> <?php } ?> </div> <div class="pike_prev"></div> <div class="pike_next"></div> <div class="pike_spot"></div> </div> </div> <div class="phpcn-col-md3" > <img class="phpcn-r banner-right" src="static/images/banner-right.jpg"> </div> </div> <!--幻灯片结束--> <!--新聞開始--> <div class="home-news phpcn-mt-30"> <div class="title phpcn-mb-20"> <a href="" class="tit">新闻资讯</a> <span class="phpcn-r"><a href="">更多</a></span> </div> <div class="phpcn-clear"> <div class="phpcn-col-md4"> <img src="static/images/news.jpg"> </div> <?php foreach($news as $val){ ?> <div class="phpcn-col-md4"> <h3><a href="" ><?php echo $val['title']; ?></a></h3> <ul> <?php foreach($val['content'] as $ttt){ ?> <li> <span>[<?php echo $ttt['type']; ?>]</span> <a href=""><?php echo $ttt['biaoti']; ?></a> </li> <?php } ?> </ul> </div> <?php } ?> </div> <div class="phpcn-clear phpcn-mt-30"> <div class="phpcn-col-md4"> <dl class="pic"> <dd class="phpcn-col-md6"> <a href=""> <img src="static/images/n-2.jpg"> <span>三星Note10/10+发布<br>搭载挖孔前摄</span> </a> </dd> <dd class="phpcn-col-md6"> <a href=""> <img src="static/images/n-3.jpg"> <span>小米公布6400万<br>和1亿像素手机信息</span> </a> </dd> </dl> </div> <?php foreach($news as $val){ ?> <div class="phpcn-col-md4"> <h3><a href="" ><?php echo $val['title']; ?></a></h3> <ul> <?php foreach($val['content'] as $ttt){ ?> <li> <span>[<?php echo $ttt['type']; ?>]</span> <a href=""><?php echo $ttt['biaoti']; ?></a> </li> <?php } ?> </ul> </div> <?php } ?> </div> </div> <!--新聞開始結束--> </div> <!--LOGO与搜索结束---> <!--图片开始--> <div class="phpcn-clear phpcn-mt-30" style='background:#eee;'> <div class="phpcn-main"> <div class="phpcn-clear home-img"> <div class="title-header phpcn-mb-40 phpcn-mt-20"><span>图片专区</span></div> <div class=" phpcn-clear phpcn-col-space15"> <?php foreach($girl as $val){ ?> <div class="phpcn-col-md4"> <div class="bg"> <div class="title "><a href=""><?php echo $val['title']; ?></a> <span><?php echo $val['biaoti']; ?></span></div> <ul class="phpcn-clear"> <?php foreach($val['content'] as $kkk){ ?> <li class="phpcn-col-md6"> <a href=""> <img src="<?php echo $kkk['src']; ?>"> </a> <a href=""><?php echo $kkk['text']; ?></a> </li> <?php } ?> </ul> </div> </div> <?php } ?> </div> </div> <!--图片开始结束--> <!--商城开始--> <div class="phpcn-clear"> <div class="title-header phpcn-mb-40 phpcn-mt-20"><span>二手交易</span></div> <div class="home-shop phpcn-clear"> <?php foreach ($category as $val){ ?> <div class="title "> <a href=""><?php echo $val['title']; ?></a> <span><?php echo $val['biaoqian']; ?></span> </div> <div class='head-tags'> <span><?php echo $val['category']; ?>:</span> <?php foreach($val['tab'] as $kkk){ ?> <a href=""><?php echo $kkk; ?></a> <?php } ?> </div> <?php } ?> <div class="phpcn-clear"> <div class="phpcn-col-md8 dad"> <dl> <?php foreach ($haibao as $val){ ?> <dd class="phpcn-col-md3"> <a href=""> <img src="static/images/shop/<?php echo $val['src']; ?>"></a> <a href=""><?php echo $val['title']; ?></a> <a href="" class="phpcn-mt-10"> <span class="price"><?php echo $val['price']; ?></span> <span class="tags"><?php echo $val['tags']; ?></span> </a> </dd> <?php } ?> </dl> </div> <div class="phpcn-col-md4 home-ad"> <ul class="phpcn-clear"> <li class="phpcn-col-md6"> <a href=""> <img src="static/images/ad/1.png"> </a> </li> <li class="phpcn-col-md6"> <a href=""> <img src="static/images/ad/2.png"> </a> </li> <li class="phpcn-col-md6"> <a href=""> <img src="static/images/ad/3.png"> </a> </li> <li class="phpcn-col-md6"> <a href=""> <img src="static/images/ad/4.png"> </a> </li> </ul> <div class="phpcn-mt-10"> <a href=""> <img src="static/images/ad/image.png" class="slogan"> </a> </div> <div class="phpcn-mt-10" > <a href=""> <img src="static/images/ad/ad2.jpg" class="slogan "> </a> </div> </div> </div> </div> </div> <!--商城开始结束--> </div> </div> <!--友情链接 --> <div class="phpcn-clear phpcn-mt-30"> <div class="phpcn-main links"> <div class="title-header phpcn-mb-40 phpcn-mt-20"><span>合作网站</span></div> <div> <?php foreach ($link as $val){ ?> <a href=""><?php echo $val; ?></a> <?php } ?> </div> </div> </div> <!--友情链接结束--> <!--网站底部--> <div class="phpcn-clear phpcn-mt-30 footer"> <div class="phpcn-main"> <div class="phpcn-col-md8"> <div class="link phpcn-mb-30"> <?php foreach($about as $val){ ?> <a href="" target="_blank"><?php echo $val; ?></a> <?php } ?> </div> <div class="phpcn-col-md2 f-logo"> LOGO </div> <div class="phpcn-col-md10"> <P>2019 fengniao.com. All rights reserved . 安徽闹着玩***(无聊网)版权所有</P> <P><span>皖ICP证150110号 京ICP备14323013号-2</span> <span>皖公网安备110108024357788号</span></P> <P><span>违法和不良信息举报电话: 0551-1234567</span> <span>举报邮箱: admin@baidu.com</span></P> </div> </div> <div class="phpcn-col-md4"> <h4>关注公众号</h4> <img src="static/images/erwei-code.png"> </div> </div> </div> <!--网站底部--> <script src="static/js/pin.js"></script> <script> $(function(){ $('body').dad({ }); }); var myPi = new Pike(".pi", { type: 1, // 轮播的类型(1渐隐) automatic: true, //是否自动轮播 (默认false) autoplay: 2000, //自动轮播毫秒 (默认3000) hover: true, //鼠标悬停轮播 (默认false) arrowColor: "yellow", //箭头颜色 (默认绿色) arrowBackgroundType: 2, //箭头背景类型 (1: 方形, 2:圆形) arrowBackground: 1, //箭头背景色 (1:白色,2:黑色, 默认:无颜色) arrowTransparent: 0.2, //箭头背景透明度 (默认: 0.5) spotColor: "white",//圆点颜色 (默认: 白色) spotType: 1, //圆点的形状 (默认: 圆形, 1:圆形, 2.矩形) spotSelectColor: "red", //圆点选中颜色 (默认绿色) spotTransparent: 0.8, //圆点透明度 (默认0.8) mousewheel: true, //是否开启鼠标滚动轮播(默认false) drag: false, //是否开启鼠标拖动 (默认为: true, 如不需要拖动设置false即可) loop: true, //是否循环轮播 (默认为: false) }); var progress = $('.phpcn-progress .phpcn-row'); jQuery.each(progress, function(){ //console.log($(this).find('.phpcn-progress-percent').attr('class')); $(this).find('.phpcn-progress-bor').css('width',$(this).find('.phpcn-progress-percent').html()); }); $('.phpcn-dl dl').last().css('border-bottom','1px solid #C9C9C9'); $('#admin-select').mouseover(function(){ //alert($(this).find('dl').css('display')); $(this).find('dl').show(); }); $('#admin-select').find('dl').mouseout(function(){ $(this).hide(); }); $('.phpcn-button').mouseover(function(){ $(this).addClass('phpcn-button-hover'); });$('.phpcn-button').mouseout(function(){ $(this).removeClass('phpcn-button-hover'); }); $('.tree').css('min-height',$(document).height()-160); $('.tree').find('li').click(function(){ //alert($('.tree').find('dl').css('display')); //$('.tree').find('dl').hide(); if($(this).find('dl').css('display')=='none'){ $(this).find('i').removeClass('phpcn-icon-down'); $(this).find('i').addClass('phpcn-icon-up'); $('.tree').find('dl').hide(); $(this).find('dl').show(); }else{ $(this).find('i').removeClass('phpcn-icon-up'); $(this).find('i').addClass('phpcn-icon-down'); $(this).find('dl').hide(); } }); //table窗口 $('.tree').find('a').click(function(){ //alert($('.tree').find('dl').css('display')); //$('.tree').find('dl').hide(); var tabs=$('.phpcn-tab-title a'); tree=$(this); jQuery.each(tabs, function(){ $('.phpcn-tab-title li').removeClass('on'); if($(this).attr('data')!=tree.attr('data')){ var tabs=$('.phpcn-tab-title ul'); $(this).removeClass('on'); var html='<li class="on"><i></i><dd>'+tree.html()+' <a class="phpcn-icon phpcn-icon-guanbi" data='+tree.attr('data')+' href="javascript:;"></a></dd></li>'; tabs.append(html); return false; } }); }); //table窗口 $('.phpcn-tab-title').find('.phpcn-icon-guanbi').click(function(){ alert(); $(this).parent().parent('li').remove(); }); $('.phpcn-tab-title').find('li').mouseover(function(){ var i=$(this).find('i'); $('.phpcn-tab-title').find('li').find('i').css('width','0%'); if($(this).css('background')!='#f6f6f6'){ $('.phpcn-tab-title').find('li').css('background','none'); $(this).css('background','#f6f6f6'); } if(i.css('width')!='100%'){ i.css('width','100%'); } }); </script> </body> </html>
点击 "运行实例" 按钮查看在线实例
数据文件:
<?php // nav导航 $nav = [ '网站首页', '专题', [ '网站导航' ], '网站导航', '二手商品', '讨论区' ]; // logo图标 $logo = ['src'=>"static/images/logo.png"]; // 菜单 $caidan = [ [ 'classa'=>"phpcn-col-md3", 'classb'=>"phpcn-icon-gongdan", 'title'=>'咨讯看学', 'cai'=>[ '器材','大师','学院','影赛','器材','大师','学院','影赛' ] ], [ 'classa'=>'phpcn-col-md2', 'classb'=>'phpcn-icon-renwujincheng', 'title'=>'排球天地', 'cai'=>[ '器材','大师','学院','影赛' ] ], [ 'classa'=>'phpcn-col-md2', 'classb'=>'phpcn-icon-gongdan', 'title'=>'摄影天地', 'cai'=>[ '器材','大师','学院','影赛' ] ], [ 'classa'=>'phpcn-col-md4', 'classb'=>'phpcn-icon-DOC', 'title'=>'娱乐世界', 'cai'=>[ '土豆','西瓜','鸡蛋','西红柿','青菜','洋葱', '土豆','西瓜','鸡蛋','西红柿','青菜','洋葱' ] ], ]; // 轮播图 $banner = [ [ 'src'=>"static/images/1.jpg", 'alt'=>"" ], [ 'src'=>"static/images/2.jpg", 'alt'=>"" ], [ 'src'=>"static/images/3.jpg", 'alt'=>"" ], [ 'src'=>"static/images/4.jpg", 'alt'=>"" ], ]; // 新闻资讯 $news = [ [ 'title'=>"性价比广角 ***17-28F2.8评测", 'content'=>[ ['type'=>'新闻','biaoti'=>"佳能注册相机无线充电和眼控对焦专利"], ['type'=>'新闻','biaoti'=>"Entaniya宣布推出Super 35 PL卡口鱼***头"], ['type'=>'新闻','biaoti'=>"佳能注册相机无线充电和眼控对焦专利"], ['type'=>'新闻','biaoti'=>"轻便灵巧可变形 JOBY入门迷你三脚架套装试用"], ] ], [ 'title'=>"性价比广角 ***17-28F2.8评测", 'content'=>[ ['type'=>'新闻','biaoti'=>"佳能注册相机无线充电和眼控对焦专利"], ['type'=>'新闻','biaoti'=>"Entaniya宣布推出Super 35 PL卡口鱼***头"], ['type'=>'新闻','biaoti'=>"佳能注册相机无线充电和眼控对焦专利"], ['type'=>'新闻','biaoti'=>"轻便灵巧可变形 JOBY入门迷你三脚架套装试用"], ] ], ]; // girl $girl = [ [ 'title'=>"美女", 'biaoti'=>"小黄摄影艺术", 'content'=>[ ['src'=>"static/images/img1.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img2.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img3.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img4.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ] ], [ 'title'=>"帅哥", 'biaoti'=>"大黄摄影艺术", 'content'=>[ ['src'=>"static/images/img1.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img2.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img3.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img4.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ] ], [ 'title'=>"老头", 'biaoti'=>"老黄摄影艺术", 'content'=>[ ['src'=>"static/images/img1.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img2.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img3.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ['src'=>"static/images/img4.jpg",'text'=>'阴沉夏日的柔美身姿 复古少女的藕荷色心情'], ] ], ]; // 热门分类 $category = [ [ 'title'=>'抢好货', 'biaoqian'=>"0低价、便捷、安全、快速", 'category'=>'热门分类', 'tab'=>[ "小狗",'小猫','小猪','鸭子','小虎' ] ] ]; // 海报写真 $haibao = [ [ 'src'=>"shop1.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], [ 'src'=>"shop2.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], [ 'src'=>"shop3.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], [ 'src'=>"shop4.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], [ 'src'=>"shop5.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], [ 'src'=>"shop3.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], [ 'src'=>"shop4.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], [ 'src'=>"shop5.jpg", 'title'=>"这是标题", 'price'=>"50", "tags"=>"小猫" ], ]; $link = [ 'php中文网','百度','phpstudy','万达','中国银行', 'php中文网','百度','phpstudy','万达','中国银行', 'php中文网','百度','phpstudy','万达','中国银行', ]; $about = [ '简介','联系我们','友情链接','招聘信息','用户协议', '隐私声明','法律投诉' ]; ?>
点击 "运行实例" 按钮查看在线实例
总结:
1、数据的输出基本上都是数组形式;
2、基本数组(一维数组)的标准输出格式:
<?php
foreach($about as $val){
?>
<a href=""><?php echo $val; ?></a>
<?php
}
?>
//对应的数组——$about
$about = [
'简介','联系我们','友情链接','招聘信息','用户协议', '隐私声明','法律投诉'
];
3、多维数组的标准输出格式
<?php
foreach ($category as $val){
?>
<div class="title ">
<a href=""><?php echo $val['title']; ?></a>
<span><?php echo $val['biaoqian']; ?></span>
</div>
<div class='head-tags'>
<span><?php echo $val['category']; ?>:</span>
<?php
foreach($val['tab'] as $kkk){
?>
<a href=""><?php echo $kkk; ?></a>
<?php
}
?>
</div>
<?php
}
?>
//对应的数组——$category
// 热门分类
$category = [
[
'title'=>'抢好货',
'biaoqian'=>"0低价、便捷、安全、快速",
'category'=>'热门分类',
'tab'=>[ "小狗",'小猫','小猪','鸭子','小虎' ]
]
];