Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как удалить дубликаты в массиве?


AnnaBez
 Share

Recommended Posts

  {% for product in products %}
                        <div class="product-block">
                            <div class="product-left">
                                <div class="store_name">
                                    {% if product['store_name'] not in products %}
                                        Продавец {{ product['store_name'] }}
                                    {% endif %}
                                </div>
                        <div class="image ">
                            {% if product['thumb'] %}
                                <a href="{{ product['href'] }}"><img src="{{ product['thumb'] }}" alt="{{ product['name'] }}" title="{{ product['name'] }}" /></a>
                            {% endif %}
                        </div>
                            </div>
                            <div class="product-right">
                        <div class="name">
                            <a href="{{ product['href'] }}">{{ product['name'] }}</a>
                         </div>
                          	</div>
                        </div>
              
                {% endfor %}

Массив выводит данные о товарах в корзине.

Я пыилась что-то сгделать наподобие этого, чтобы не выводились дубликаты массива 

 {% if product['store_name'] not in products %}
                                        Продавец {{ product['store_name'] }}
                                    {% endif %}

Есть функция в PHP 

array_unique(); 

Но не нашла как ее в twig использовать. Может быть кто подскажет ?

Link to comment
Share on other sites


12 минут назад, AnnaBez сказал:

Но не нашла как ее в twig использовать. Может быть кто подскажет ?

потому что использовать ее нужно не в шаблоне, а в котроллере ггде этот массив данных формируется. 

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.