Wednesday, 28 January 2015

Sort Array

As discussed in previous example about B.I.F (built in functions) php also have some bif for sort an  array:

  • sort() - sort arrays in ascending order
  • rsort() - sort arrays in descending order
  • asort() - sort associative arrays in ascending order, according to the value
  • ksort() - sort associative arrays in ascending order, according to the key
  • arsort() - sort associative arrays in descending order, according to the value
  • krsort() - sort associative arrays in descending order, according to the key.

Method to use them:
 declare array first , write method which one want to use eg:
sort($arrayname);
it will sort array in ascending order


No comments: