title: How to arrange item data from MySQL database like given my example
body: <p>how to arrange below list any way in php,</p>
  
  <p>Actually we will get item array list from <strong>MySQL Database(Select Output)</strong>.</p>
  
  <p>For example, </p>
  
  <p>If We will get Array list like below </p>
  
  <pre><code>$item_arr = array("102","101","103","103","101","101","102","103","102");
  </code></pre>
  
  <p>The We have to arrange like below,</p>
  
  <pre><code>101 102 103 101 102 103 101 102 103 
  </code></pre>
  
  <p>Again If Array list like below,</p>
  
  <pre><code>$item_arr = array("102","103","102","101","103","101","103","103","101");
  </code></pre>
  
  <p>The We have to arrange like below,</p>
  
  <pre><code>101 102 103 101 103 103 101 102 103
  </code></pre>
  
  <p>Again If Array list like below,</p>
  
  <pre><code>$item_arr = array("103","101","102","103","102","102","102","103","102");
  </code></pre>
  
  <p>The We have to arrange like below,</p>
  
  <pre><code>101 102 103 102 102 103 102 102 103
  
  $rtr_item_arr = arrange_item($item_arr);
  function arrange_item($results)
  {
      $last_val="";
      $unique_only = array();
      $additional = array();
      foreach($results as $val):
  
          if(in_array($val, $unique_only)):
              $additional[] = $val;
          endif;
  
          if($val != $last_val  &amp;&amp; !in_array($val,$unique_only)):
              echo $val." ";
              $unique_only[] = $val;
          endif; 
          $last_val = $val;
  
      endforeach;
  
      $additional = array_filter($additional);
      if(!empty($additional)):
          arrange_item($additional);
      endif;
  }
  </code></pre>
  
  <p>How to arrange it to keep similarity On the Other hand, how to arrange nicely.</p>
  
  <p>Please any suggestion? </p>