开发者

PHPTAL and CSV in array

I have data in CSV format:

$result->names = array(array('x,y,z'),array('a,b,c'));

for example:

item.names = 'a,b,c'

this code doesn't work:

<div tal:repeat="item result">
<div tal:repeat="x php开发者_如何学编程:explode(',',${item.names})" tal:omit-tag="">
<span tal:content="x"></span>
</div></div>

but this code works, why?

<div tal:repeat="item result">
<div tal:repeat="x php:explode(',','a,b,c')" tal:omit-tag="">
<span tal:content="x"></span>
</div></div>


Don't use ${} in expressions with php: modifier. That should work, assuming you're looping over value from $result->names:

<tal:block tal:repeat="x php:explode(',', item)">

(BTW: instead of omit-tag you can use tal:block element which is "invisible")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜