【发布时间】:2016-02-25 05:14:44
【问题描述】:
我在 php 页面中有一个多维数组,如下所示:
$comment=Array
(
[655436] =>
[655435] => Array
(
[id] => 5864928
[shortmessage] => rytrht
)
[655434] => Array
(
[id] => 5864934
[shortmessage] => vcxv
)
[654990] =>
[654989] => Array
(
[id] => 5864948
[shortmessage] => fgfj
)
[654983] => Array
(
[id] => 5864909
[shortmessage] => state
)
[654981] =>
[654979] =>
[654978] => Array
(
[id] => 5864933
[shortmessage] => ggjj
)
[654329] => Array
(
[id] => 5864974
[shortmessage] =>
)
)
echo $renderer->render('sample.html', array( 'index' => commentId,'Comment' => $comments));
我希望使用 Django 模板在 HTML 页面中使用 $comment 数组值而不循环数组
示例.html:
<td><input class="Comment" type="text" value="{{Comment[index]['shormessage']}}" /></td>
但是{{Comment[index]['shormessage']}} 没有给出任何值并且整个页面本身没有显示
我不知道如何访问多维数组。
有什么办法吗?
【问题讨论】:
-
您的问题有点令人困惑,您在 php 项目中究竟是如何使用 django 的?
-
在我的 php 页面中我使用了 render() 并且在 html 页面中使用了 django
-
@Nithya,就
php吧,不要让你的生活复杂化,php.net/manual/en/function.vsprintf.php
标签: php html django multidimensional-array