Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak sprawdzić czy następna wartość jest taka sama
silverwind
post
Post #1





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 8.02.2013

Ostrzeżenie: (0%)
-----


Jak zrobić test, który sprawdza czy kolejna wartość w pętli foreach jest taka sama. Jest tak funkcja same as w twigu ale nie mam pomysłu jak to zrobić
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




Miales taki kod:
{% set foo = details.o_name%}
{% if foo == details.o_name %}

<th class="text-center "></th>
{% else %}
<th class="text-center ">{{details.o_name}}</th>
{% endif %}

jedyne co miales zrobic, to przeniesc set za IF:
{% if foo == details.o_name %}

<th class="text-center "></th>
{% else %}
<th class="text-center ">{{details.o_name}}</th>
{% endif %}
{% set foo = details.o_name%}


Dodatkowo przed PETLA daj
{% set foo = '' %}
aby foo mialo jakas poczatkowa wartosc
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.12.2025 - 13:23