Foreach remove duplicate images

1

I have code below that pulls the images of the products of the magento shopping cart, however it is displaying duplicate, ie when it lists the images it displays twice the same image.

<?php 
    $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems() ;  

        foreach($items as $item) {                                   
            echo '<img style="width: 75px; height: 75px;" src="'.$this->helper('catalog/image')->init($item->getProduct(), 'small_image').'"/>';

        }

?>

I would like to display only once, end this loop .

    
asked by anonymous 10.11.2015 / 19:02

1 answer

1

array_unique($array)

<?php 
    $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems() ;  

    $items = array_unique($items);

        foreach($items as $item) {                                   
            echo '<img style="width: 75px; height: 75px;" src="'.$this->helper('catalog/image')->init($item->getProduct(), 'small_image').'"/>';

        }

?>
    
10.11.2015 / 19:07