smarty循環(huán)array-map顯示
y.html 模板文件
<ul>
{{{section name=item loop=$menu_item}}}
<li><a href="{{{$menu_item[item][0]}}}">{{{$menu_item[item][1]}}}</a></li>
{{{/section}}}
<!--
格式
<li><a href="#">Index</a></li>
<li><a href="#">Selected Content</a></li>
<li><a href="#">Guestbook</a></li>
<li><a href="#">Toggle Sidebar</a></li>
<li><a href="#">Login</a></li>
-->
</ul>
head.php
<?php

require 'lib/Smarty-2.6.11/libs/Smarty.class.php';

$smarty = new Smarty;

//$smarty->compile_check = true;
//$smarty->debugging = true;
$smarty->left_delimiter = "{{{";
$smarty->right_delimiter = "}}}";

$site_title ="中文";
?>ini.php
<?php
define('SITE_TITLE','中文');
define('SITE_LINK','');
define('AUTHER','bluesky');
define('BABY','');
define('WATCH','');
define('BLOG_TITLE','HELLOWORLD,BLOG');
define('BLOG_INDEX_LINK','HTTP://localhost:88/yy/xy.php');
?>
xy.php
<?php

//echo dirname(__FILE__);

require 'head.php';
require 'ini.php';

$page = 'y.html';
define('PAGE_TITLE','中國');
$smarty->assign('site_title',SITE_TITLE);
$smarty->assign('page_title',PAGE_TITLE);
$smarty->assign('blog_title',BLOG_TITLE);
$smarty->assign('blog_index_link',BLOG_INDEX_LINK);

$href = array();
$value = array();
$href[1] = 'index.php'; $value[1] = '首頁';
$href[2] = 'guest.php'; $value[2] = '留言本';
$href[3] = 'about.php'; $value[3] = '關(guān)于';
$href[4] = 'link.php'; $value[4] = '鏈接';


$map = array_map(null,$href,$value);

for($index=0;$index<count($c);$index++){
//echo "<a href=".$c[$index][0].">";
//echo $c[$index][1]."</a><br/>";
}

//return;
$smarty->assign('menu_item',$map);

$smarty->display($page);
?>














head.php






















xy.php


































posted on 2005-12-30 14:22 bluesky 閱讀(1666) 評論(0) 編輯 收藏 所屬分類: PHP