我在我的模板文件中的以下代碼:如何解析/解碼smarty模板中的JSON對象?
{foreach from=$items item=entry}
<pre>
{$entry->nb_persons|@print_r}
</pre>
{/foreach}
輸出是(JSON字符串):
{"ip":"12.12.12.12","date":1375616434,"cartitems":["foo:1"],"company":"dsad","FirstName":"sad","LastName":"asdsad","street":"","postcode":"","city":"","country":"Andorra","phone":"456456","fax":"","email":"[email protected]","comefrom":"google","request":"","message":"sadads"}
我想打印的每個元素分隔,爲例如:
{$entry->nb_persons.company}
應該給我 - > 「DSAD」
但這不是工作,我不知道爲什麼。
你是什麼意思分開? –
謝謝Jhon'我的意思是隻打印上面{$ entry-> nb_persons.company} - >「dsad」的值。再次感謝... – cookie669