更新数组smarty

时间:2010-06-25 09:35:12

标签: smarty

在smarty我有这个数组:

{$user}
Array (3)
0 => Array (2)
  id => "1"
  name => "Peter"
1 => Array (2)
  id => "2"
  name => "Joy"
2 => Array (2)
  id => "3"
  name => "Sandra"

我如何更新此数组(使用php)? 插入新元素,年龄:

Array (3)
0 => Array (2)
  id => "1"
  name => "Peter"
  age => "16"
1 => Array (2)
  id => "2"
  name => "Joy"
  age => "17"
2 => Array (2)
  id => "3"
  name => "Sandra"
  age => "20"

1 个答案:

答案 0 :(得分:2)

我会用PHP定义数组。 然后使用$ smarty-> assign()将其发布到smarty模板。