how can i check if a php associative array's key is equal to a defined variable from phptal condition?

StackOverflow https://stackoverflow.com/questions/10336369

문제

i've this problem my phptal view has a variable called data which is an associative array.

Let's suppose that i've those Keys M01 M02 and M03 not in a particular order, i've to print to the user view all the data not referred by key M02.

How can i do this? Thanks in advance

Marco

UPDATE: I forgot to say that i cannot edit the code which calls the view.

도움이 되었습니까?

해결책

If order is important, use second array with ordered keys to print:

<div tal:repeat="key php:array('M01','M03')" tal:content="array/$key"/>

Otherwise you can just add a condition:

<div tal:repeat="data array">
    <tal:block tal:condition="php:repeat.data.key != 'M02'" tal:content="data"/>
</div>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top