title: Sort a multi dimendional PHP variable
body: <p>I am using an XML API service &amp; SOAP to get some data. I am using the below code to sokut the hotelCode (multi dimensional valiable ).</p>
  
  <pre><code> &lt;?php
  $hotelCodes = array() ;
  $availHotels = $checkAvailability-&gt;availableHotels ;
  foreach($availHotels as $hotel){
      $hotelCodes[] = $hotel-&gt;hotelCode ;
  }
  ?&gt;
  </code></pre>
  
  <p>And below i echoing them</p>
  
  <pre><code>    &lt;li&gt;
      &lt;?php echo $hotelCodes[0];?&gt;&lt;/li&gt;
      &lt;li&gt;
      &lt;?php echo $hotelCodes[1];?&gt;&lt;/li&gt;
      &lt;li&gt;
      &lt;?php echo $hotelCodes[2];?&gt;
      &lt;/li&gt;
      &lt;li&gt;
      &lt;?php echo $hotelCodes[3];?&gt;
      &lt;/li&gt;
  </code></pre>
  
  <p>The think that SOAP responds with all the availeble hotelcodes that are availeble for that certain search that i made.
   i receive the response as below example:</p>
  
  <pre><code> - ABCDE - This is Hotel Code 0 and it the code of Hotel Y / Double standard Room / Room Only
   - ABCDE - This is Hotel Code 0 and it the code of Hotel Y / Double standard Room / Breakfast
   - ZXCVB - This is Hotel Code 0 and it the code of Hotel X / Double standard Room / Room Only
   - ABCDE - This is Hotel Code 0 and it the code of Hotel Y / Twin Toom / Room Only
  </code></pre>
  
  <p>The <code>print_r($hotelCodes);</code> is</p>
  
  <pre><code>Array ( [0] =&gt; ABCDE [1] =&gt; ABCDE[2] =&gt; ZXCVB [3] =&gt; ABCDE)
  </code></pre>
  
  <p>How can i sort the <code>$hotelCodes[]</code> so i can get unique values ( unique hotel codes ) </p>
  
  <p>I am trying now:</p>
  
  <pre><code>&lt;?php
  $hotelCodes = array() ;
  $availHotels = $checkAvailability-&gt;availableHotels ;
  foreach($availHotels as $hotel){
      $hotelCodes[] = $hotel-&gt;hotelCode ;
      $result = array_unique($hotelCodes);
  print_r($result);
  }
  ?&gt;
  </code></pre>
  
  <p>Print_r is :</p>
  
  <pre><code>Array ( [0] =&gt; ITOI6P ) Array ( [0] =&gt; ITOI6P [1] =&gt; ITR03M ) Array ( [0] =&gt; ITOI6P [1] =&gt; ITR03M ) Array ( [0] =&gt; ITOI6P [1] =&gt; ITR03M [3] =&gt; ITJ64C ) Array ( [0] =&gt; ITOI6P [1] =&gt; ITR03M [3] =&gt; ITJ64C ) Array ( [0] =&gt; ITOI6P [1] =&gt; ITR03M [3] =&gt; ITJ64C [5] =&gt; ITRC24 )
  </code></pre>
  
  <p>And the echo are :</p>
  
  <pre><code>&lt;li&gt;&lt;?php echo $result[0];?&gt;&lt;/li&gt; - displays : ITOI6P
  &lt;li&gt;&lt;?php echo $result[1];?&gt;&lt;/li&gt; - displays : ITR03M
  &lt;li&gt;&lt;?php echo $result[2];?&gt;&lt;/li&gt; - displays : empty
  &lt;li&gt;&lt;?php echo $result[3];?&gt;&lt;/li&gt; - displays : ITJ64C
  &lt;li&gt;&lt;?php echo $result[4];?&gt;&lt;/li&gt; - displays : empty
  &lt;li&gt;&lt;?php echo $result[5];?&gt;&lt;/li&gt; - displays : ITRC24
  </code></pre>
  
  <p>How can i get all of them filled with the next in order unique hotel codes ?</p>