---
title: "smarty自定义变量 日期输出"
author: "myfreespace"
date: "2010-10-27T12:38:01Z"
tags: []
categories: ["编程语言"]
slug: "smarty"
draft: false
lastmod: "2011-03-02T15:30:15Z"
id: 795397
url: "https://myfreespace.iteye.com/blog/795397"
---

smarty模板中自定义变量 并应用。

{assign var="name" value=$value}

var 是变量调用的名字，用来在别的地方调用该值，

value是赋给给变量的值，可以是循环的值，也可以是自己定义的，也可以是函数执行的结果。{if $k eq 'id'}{assign var='tid' value=$item}{/if}

统计循环个数$smarty.section.num.total

统计数组个数$array|@count 

按输出的顺序显示编号 $smarty.section.num.index

 

直接输出一维数组的值

$arrone = array(a=&gt;'aaa',b=&gt;'bbb');

模板中输出为{$arrone.a}

 

$zixun\[itemzixun].addtime|date\_format:"%Y-%m-%d

%H:%M:%S"