【发布时间】:2014-09-22 14:25:35
【问题描述】:
我正在使用 SMARTY,我需要创建一个数组并将值分配给它的特定索引。
这是我的 php 代码:
$tag = str_replace('-', ' ',$_GET['tag']);
$tag = strip_tags(trim(mysql_real_escape_string(addslashes($tag)))); // the tags word variable
$smarty->assign('tag',$tag);
$tag_sql = "SELECT * FROM items WHERE item_published='0' AND item_tags LIKE '%$tag%' ";
$tag_query = mysql_query($tag_sql);
while ($tag_row = mysql_fetch_assoc($tag_query)) {
$items[] = $tag_row;
}
$smarty->assign('items',$items); // assign the items loop to smarty
当我在 smarty 模板中使用此代码时
{section name=x loop=$items } {$items[x].item_url} {/section}
html 输出是
http://google.com http://yahoo.com
我想做html输出
'http://google.com','http://yahoo.com'
【问题讨论】:
-
不清楚你想要达到什么目的。编辑您的问题并在 PHP 中显示您的数据,现在真的很难说出您想要实现的目标。
标签: arrays smarty smarty3 smarty2