Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. <?php
  2.  
  3. $commentsArray = [['comment'=>'blabla1', 'time'=>time()-3600],
  4. ['comment'=>'blabla2', 'time'=>time()-7200],
  5. ['comment'=>'blabla3', 'time'=>time()-3100]];
  6. $i = 0;
  7. foreach ($commentsArray as $arr) {
  8. $comments[$i] = $arr['comment'];
  9. $times[$i] = $arr['time'];
  10. $i++;
  11. }
  12.  
  13. array_multisort($times, $comments);
  14. echo "<pre>", print_r($comments, true), "</pre>";
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement