Re: [PHP] Re: Sorting an array

2011-03-01 Thread Alex
That or do it in mysql before you get the data back, its also pretty good at sorting, you know ;) -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. FeIn wrote: Also check http://www.php.net/manual/en/function.natsort.php On Tue, Mar 1, 2011 at 1:39 PM, David Robley wrote

Re: [PHP] Re: Sorting an array

2011-03-01 Thread FeIn
Also check http://www.php.net/manual/en/function.natsort.php On Tue, Mar 1, 2011 at 1:39 PM, David Robley wrote: > Ron Piggott wrote: > > > > > I need help to know how to sort the words / phrases in my array. > > > > Variable name: $words_used > > print_r( $words_used ); Current output: Array (

[PHP] Re: Sorting an array

2011-03-01 Thread David Robley
Ron Piggott wrote: > > I need help to know how to sort the words / phrases in my array. > > Variable name: $words_used > print_r( $words_used ); Current output: Array ( [187] => Sin [249] => > Punished [98] => Sanctuary [596] => Sing [362] => Anointing Oil ) Desired > result: Alphabetical sort:

[PHP] Re: Sorting an array by value length.

2003-10-22 Thread Justin Patrin
You want to use usort, which lets you specify a comparison function. function cmpByLength($a, $b) { return strlen($a) > strlen($b); } usort($arrayToSort, 'cmpByLength'); And change the '>' to '<' if the ordering is wrong. Rolf Brusletto wrote: Hey all - I've been scouring the php.net site for

[PHP] Re: Sorting an array

2001-09-16 Thread ~~~i LeoNid ~~
On Thu, 13 Sep 2001 11:10:03 +0200 impersonator of [EMAIL PROTECTED] (_lallous) planted &I saw in php.general: >here's your script, > .. >Kill 'em All >The Wall"; > >$mem = split("\n", $mem); Explode() is less expensive then split(), as long as you don't use regexp, which is the case here, and (

[PHP] Re: Sorting an array

2001-09-13 Thread _lallous
another case-insensitive version: "Dotan Cohen" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I'm trying to sort a listing of albums alphabetically > for LyricsList.com, the problem is that I want the > initial 'The' and 'A' in some albums (A Hard Days >

[PHP] Re: Sorting an array

2001-09-13 Thread _lallous
here's your script, "Dotan Cohen" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I'm trying to sort a listing of albums alphabetically > for LyricsList.com, the problem is that I want the > initial 'The' and 'A' in some albums (A Hard Days > Night, The Wall