title: PHP making navigation from XML attributes
body: <p>I'm trying to make a navigation made from XML database attributes. Some of the elements have the same attribute value, but when I try to echo that value only once it doesn't work. I've tried array_key_exist, in_array and array_search and not a single one works. Right now I have 2 Samsung attributes and 2 Iphone attribues. Samsung shows up 2 times, but Iphone shows only once. Can you help me out?
  PHP : </p>
  
  <pre><code>&lt;?php
          $xml = simplexml_load_file("Database/products.xml");
          $stack = array();
          foreach($xml-&gt;Mobile as $phone){
              $attr_value = $phone[0]['model'];
              $attr = (string)$attr_value;
              $link = "ponuda.php?name=".$attr;
              $array_check = array_search($attr, $stack);
              if (!($array_check)) {
                  $stack[] = $attr;
                  echo '&lt;li&gt;&lt;a href=' . $link . '&gt;' . $attr . '&lt;/a&gt;&lt;/li&gt;';
              }
          }
          ?&gt;
  </code></pre>
  
  <p>XML : </p>
  
  <pre><code>&lt;Products&gt;
      &lt;Mobile model="Samsung"&gt;
          &lt;Model&gt;Samsung Galaxy A5&lt;/Model&gt;
          &lt;Price&gt;150&lt;/Price&gt;
          &lt;Description&gt;&lt;/Description&gt;
          &lt;Picture&gt;&lt;/Picture&gt;
          &lt;Screen&gt;&lt;/Screen&gt;
          &lt;Memory&gt;&lt;/Memory&gt;
          &lt;Android&gt;&lt;/Android&gt;
      &lt;/Mobile&gt;
      &lt;Mobile model="Samsung"&gt;
          &lt;Model&gt;Samsung Galaxy A3&lt;/Model&gt;
          &lt;Price&gt;130&lt;/Price&gt;
          &lt;Description&gt;&lt;/Description&gt;
          &lt;Picture&gt;&lt;/Picture&gt;
          &lt;Screen&gt;&lt;/Screen&gt;
          &lt;Memory&gt;&lt;/Memory&gt;
          &lt;Android&gt;&lt;/Android&gt;
      &lt;/Mobile&gt;
  &lt;Mobile model="Iphone"&gt;
          &lt;Model&gt;Iphone 8&lt;/Model&gt;
          &lt;Price&gt;500&lt;/Price&gt;
          &lt;Description&gt;&lt;/Description&gt;
          &lt;Picture&gt;&lt;/Picture&gt;
          &lt;Screen&gt;&lt;/Screen&gt;
          &lt;Memory&gt;&lt;/Memory&gt;
          &lt;Android&gt;&lt;/Android&gt;
      &lt;/Mobile&gt;
      &lt;Mobile model="Iphone"&gt;
          &lt;Model&gt;Iphone 8+&lt;/Model&gt;
          &lt;Price&gt;450&lt;/Price&gt;
          &lt;Description&gt;&lt;/Description&gt;
          &lt;Picture&gt;&lt;/Picture&gt;
          &lt;Screen&gt;&lt;/Screen&gt;
          &lt;Memory&gt;&lt;/Memory&gt;
          &lt;Android&gt;&lt;/Android&gt;
      &lt;/Mobile&gt;
  &lt;/Products&gt;
  </code></pre>