0
這真的讓我難住,不知道爲什麼我不能讓它工作。使用Twig嵌套數組問題
我有一個名爲'posts'的變量。其中包含以下內容。
array(2) { ["data"]=> array(5) {
[0]=> array(3) {
["full_picture"]=> string(98) "https://www.website.com/picture.jpg"
["message"]=> string(613) "long message here"
["id"]=> string(32) "000000000" }
[1]=> array(3) {
["full_picture"]=> string(98) "https://www.website.com/picture.jpg"
["message"]=> string(613) "long message here"
["id"]=> string(32) "000000000" }
[2]=> array(3) {
["full_picture"]=> string(98) "https://www.website.com/picture.jpg"
["message"]=> string(613) "long message here"
["id"]=> string(32) "000000000" }
[3]=> array(3) {
["full_picture"]=> string(98) "https://www.website.com/picture.jpg"
["message"]=> string(613) "long message here"
["id"]=> string(32) "000000000" }
[4]=> array(3) {
["full_picture"]=> string(98) "https://www.website.com/picture.jpg"
["message"]=> string(613) "long message here"
["id"]=> string(32) "000000000" }
}
["paging"]=> array(2) {
["previous"]=> string(324) "website.com/link"
["next"]=> string(306) "website.com/link" }
}
我想使用樹枝來顯示使用樹枝標記數據數組中的嵌套數組中的值。
此刻,我有如下
{% for post in posts %}
{{ post.data.message }}
{{ endfor }}
我自己也嘗試沒有成功以下。
{% for key, post in posts %}
{{ post.data.message }}
{{ endfor }}
任何指導我錯誤的地方會很好。謝謝。
嗨,感謝您的建議。我試了兩次,他們都沒有工作。 –