Webmaster Forum
Go Back   Webmaster Forums UK SEO SEM Webmaster Community Forum - UKWW > Web Design and Website Development > Programming > PHP Forum
Register FAQ Members List Downloads Calendar Today's Posts Webmaster Resources Webmaster Blogs

UK Web Hosting
UK Web Hosting
Website Hosting
Website Hosting
UK One Way
UK One Way
Free Website Thumbnail Creator
 
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-24-2008, 08:11 PM
dman_2007
Guest
 
Posts: n/a
iTrader: / %
Default Tip : Sorting arrays in PHP

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.
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 05-28-2008, 07:39 AM
garima's Avatar
Junior Member
 
Join Date: May 2008
Posts: 17
iTrader: 0 / 0%
Thanks: 0
Thanked 0 Times in 0 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
garima is on a distinguished road
Default

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.
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
Reply

Bookmarks

Webmaster Resources
UK Web Hosting
UK WW SEO Tools
Free site submission
Web Directory
 
Advertisement
Get top 10 exposure
 
Site Of the Month
BizzFace
Nominate site of the month
 
Tag Cloud
2 columns admins wanted advice ajax article submistion bbpress best site bid bidding directory blog post butterflies coda community concentration digg directories submission directory directory network domain name dzone ecommerce ecommerce poll forum posting free free download free hosting free web hosting generate revenue google google serps icq intel internet internet spending james in london jokes keywords limitations lightbox linux and windows server microsoft mod modeling moderators wanted mootools msn music online newbie not possible online retail online spending owg in london paid forum posting photography php reddit review review website scripts search engine seo social bookmarking special discount submission thank you theme web hosting website of the month win a network wordpress xhtml

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



All times are GMT. The time now is 12:37 AM.

UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons.
Subscribe to our feeds   Subscribe to our feeds

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151