title: questions on sort array by time in php
body: <p><strong>---array $points----</strong> </p>
  
  <pre><code>Array
      (
          [0] =&gt; Array
              (
                  [0] =&gt; 2011-10-02 05:30:00
                  [1] =&gt; 20
              )
  
          [1] =&gt; Array
              (
                  [0] =&gt; 2011-10-04 09:30:00
                  [1] =&gt; 12
              )
  
          [2] =&gt; Array
              (
                  [0] =&gt; 2011-10-01 13:30:00
                  [1] =&gt; 25
              )
  
          [3] =&gt; Array
              (
                  [0] =&gt; 2011-10-03 02:30:00
                  [1] =&gt; 31
              )
  
      )
  </code></pre>
  
  <p>I have an array at above and would like to sort this array by time. Then I used the code as following to sort and result is correct. However, if I changed the  code <code>time[$key] = $val[0]</code> to <code>$time = $val[0]</code>, the result is wrong. </p>
  
  <p>Is there anyone can explain this to me? Many thanks!</p>
  
  <pre><code>foreach($points as $key=&gt;$val){
  
          $time[$key] = $val[0];
  
          array_multisort($time, SORT_ASC, $points);
      }
  </code></pre>