![]() |
|
|||||||
| Register | FAQ | Members List | Downloads | Calendar | Today's Posts | Search | Webmaster Resources | Webmaster Blogs |
![]() UK Web Hosting |
![]() Website Hosting |
![]() UK One Way |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
You can use following set of functions to sort arrays in php :
1) sort & rsort Sort takes array to be sorted as its first required parameter and sort_flags as its second optuional parameter. It sorts the array as well as reindexes it assigning elements 0 based numeric keys and removing any keys assigned prior to sorting. sort_flags parameter can be used to specify how the array is to be sorted, possible values are : a) SORT_REGULAR : regular sorting, items are compared normally and types are not changed b) SORT_NUMERIC : array elements are compared numerically c) SORT_STRING : array elements are compared as strings d) SORT_LOCALE_STRING : array elements are compared as string based on the current locale rsort function is similar to sort function except that it sorts the array inreverse order i.e. highest to lowest. 2) asort & arsort asort and arsort is basically used for sorting associative array. The main difference between sort and asort is that array elements retain their original keys and array is not reindexed. 3) ksort & krsort Similar asort and arsort functions, the only difference is that the array is sorted based on the key values instead of element values. 4) usort & uksort These functions are similar sort and ksort in functionality. Only difference is that you can specify a custom callback function as second parameter to specify the custom ordering of the array elements. 5) natsort & natcasesort natsort function sorts alphanumeric array elements as humans would do known as natural ordering (for example, 'img2' ahead of 'img10') while maintaining the key value relationship of array elements. natcasesort is the case insensitive version of the natsort function. |
|
|||||
|
multisort :-
syntax:- array_multisort(array1,sorting order,sorting type,array2,array3...) usort:- The usort() function sorts an array by a user defined comparison function. syntax:- usort(array,sorttype); __________________________________________________ _____________ Web site Design Last edited by garima; 05-28-2008 at 08:31 AM. |
![]() |
| Bookmarks |
| Webmaster Resources |
| • UK Web Hosting • UK WW SEO Tools • Free site submission • Web Directory |
| Advertisement |
![]() |
| Site Of the Month |
![]() Nominate site of the month |
|
|
| UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons. |
| Subscribe to our feeds |