PHP tips : how to sort and reverse sort an array


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Let’s say you had an array as following :

$time = array ("0600", "0000", "1200", "1800");

but you wanted it to be shown as

  1. 0000
  2. 0600
  3. 1200
  4. 1800

Use asort function..

asort ($time);

But you might also want to reverse order it.
Which is to show the latest possible date and time ..

arsort ($date_time_list);

Reference :
http://www.php.net/manual/en/function.asort.php
http://www.php.net/manual/en/function.arsort.php

Related Post

3 Responses

  1. Joey says:

    Hi there would you mind stating which blog platform
    you’re working with? I’m looking to start my own blog
    in the near future but I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m
    looking for something unique. P.S Apologies
    for being off-topic but I had to ask!

    Reply
    • Namran Hussin says:

      Hi Joey,
      At the moment am using wordpress as my blogging platform.
      So far am I feel comfortable with it.

      I did tried few other platform before but doesn’t last long
      Enough for me to know inside out about each one.

      Hopefully that would help.
      Thanks for dropping by.

      Reply
  2. recycled business card paper says:

    Hello! I simply want to give an enormous thumbs up for
    the nice info you will have here on this post. I might be coming back to your blog
    for extra soon.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *