在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"
答案 0 :(得分:2)
我会用PHP定义数组。 然后使用$ smarty-> assign()将其发布到smarty模板。