title: Unable to convert array according to date time value in php
body: <p>I have a array named $itemIds and it consists of the following datas. The key is the items id and the value is the date time that can be converted to a readable date.What I want to do is simply sort the order of the array according to the value (time). I'm totally new to php and some examples or tips would be great ! I would love to hear from you.</p>
  
  <pre><code>Array
  (
      [10477] =&gt; 1508898726
      [10549] =&gt; 1508898744
      [10891] =&gt; 1508898752
  )
  </code></pre>
  
  <p>If I use this code I get the following data from the print_r.</p>
  
  <pre><code>if (isset($itemIds)) {
      $time = array();
      foreach ($itemIds as $key =&gt; $val) {
          print_r($key.'=&gt;'.date('m/d/Y H:i:s', $val));
      }
  }
  </code></pre>
  
  <p>The problem starts from here.I want to sort(asc &amp; desc) the $itemsIds according to the date time.</p>
  
  <pre><code>10477 =&gt; 10/25/2017 11:32:06
  10549 =&gt; 10/25/2017 11:32:24
  10891 =&gt; 10/25/2017 11:32:32
  </code></pre>
  
  <p>I want to sort the data  then use array_keys($shopIds) to change it like the following data </p>
  
  <pre><code>Array
  (
      [0] =&gt; 10477
      [1] =&gt; 10549
      [2] =&gt; 10891
  )
  </code></pre>