Remove the element foreach if its properties are the same



  • There's a lot of goods where every product is presented as a cure with properties. ->id->name->price etc.). When the goods are on the page through foreach, there are cases where two of the same are produced with the same goods. ->id♪ Why don't we figure this out, it's Virtuemart, it's easier to take out the duplicate foreach'e and leave just one thing with the same thing. ->idbut I don't know how to do that. I mean, you need something like that:

    foreach($products as $product) {
        if($product->id == $product->id) {
            echo ... // вывести только один а второй такой же убрать
        }
    }
    


  • $html = Array();    
    foreach($products as $product) {
        $html[$product->id] = ''.$product->price.'';
    }
    
    echo join("", $html);
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2