Re: [PHP] Array Sorting

2006-05-05 Thread tedd
On Thu, May 4, 2006 10:20 am, James Nunnerley wrote: > What I'm not sure about doing is sorting by say Size or Date? There's several different examples of date sorts here: http://www.weberdev.com/AdvancedSearch.php?searchtype=title&search=date+sort&Submit1.x=0&Submit1.y=0 HTH's tedd --

Re: [PHP] Array Sorting

2006-05-04 Thread Richard Lynch
On Thu, May 4, 2006 10:47 am, Stut wrote: > It's worth noting that if you're not using the fact that they're > indexed > on the filename it's probably faster to use integer keys instead of > strings, but don't quote me on that. I'm not overly familiar with the > internals of PHP... yet! I think th

Re: [PHP] Array Sorting

2006-05-04 Thread Richard Lynch
On Thu, May 4, 2006 10:20 am, James Nunnerley wrote: > $file_array[$filename] = array ("Date" => $Date, "size" => $size, > "permissions" => $permissions); > > I can quite happily sort the array by filename (using natksort and > natkrsort), which I found on the php manual - and for reference have >

Re: [PHP] Array Sorting

2006-05-04 Thread Stut
James Nunnerley wrote: I think I may have written down my variable structure incorrectly in the first place, which even has me confused... The $file_array[$filename] is I don't think a further array. The "sub" values are created as follows: $file_array[$filename]["Date"] = ... $file_array[$fi

RE: [PHP] Array Sorting

2006-05-04 Thread James Nunnerley
ke by not defining $file_array[$filename]? I don't think so, but would be happy to be corrected! Cheers Nunners -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: 04 May 2006 16:24 To: James Nunnerley Cc: php-general@lists.php.net Subject: Re: [PHP] Array Sorting James N

Re: [PHP] Array Sorting

2006-05-04 Thread Stut
James Nunnerley wrote: I've got an array which has the following properties: $file_array[$filename] = array ("Date" => $Date, "size" => $size, "permissions" => $permissions); I can quite happily sort the array by filename (using natksort and natkrsort), which I found on the php manual - and fo

RE: [PHP] Array Sorting, 2 items...

2003-07-22 Thread Dan Joseph
ilto:[EMAIL PROTECTED] > Sent: Tuesday, July 22, 2003 11:25 AM > To: Dan Joseph > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Array Sorting, 2 items... > > > Your array seems like a result of mysql_fetch_array(), cannot you order > it in the sql query? > > Dan Joseph wrote:

RE: [PHP] Array Sorting, 2 items...

2003-07-22 Thread Dan Joseph
ideas? -Dan Joseph > -Original Message- > From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 22, 2003 11:39 AM > To: 'Dan Joseph'; [EMAIL PROTECTED] > Subject: RE: [PHP] Array Sorting, 2 items... > > > > -Original Message- &g

Re: [PHP] Array Sorting, 2 items...

2003-07-22 Thread Curt Zirzow
* Thus wrote Dan Joseph ([EMAIL PROTECTED]): > Eek... Yes, I did past it wrong... > > SELECT payment_methods.ba_type, loan_info.loan_number, loan_info.id AS > loan_id, cust_info.first_name, cust_info.last_name, > transactions.approved_date, payment_types.type FROM loan_info, cust_info, > transact

RE: [PHP] Array Sorting, 2 items...

2003-07-22 Thread Dan Joseph
nything wrong with that? Shouldn't that give me the sort I'm looking for without having to do a usort? -Dan Joseph > -Original Message- > From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 22, 2003 11:39 AM > To: 'Dan Joseph'; [EMAIL PROTECTE

RE: [PHP] Array Sorting, 2 items...

2003-07-22 Thread Ford, Mike [LSS]
> -Original Message- > From: Dan Joseph [mailto:[EMAIL PROTECTED] > Sent: 22 July 2003 16:29 > > Yeah, I did get it from a mysql_fetch_array(). I have: > > ORDER BY > payment_methods.ba_type ASC, > loan_info.loan_number ASC > > H

RE: [PHP] Array Sorting, 2 items...

2003-07-22 Thread Dan Joseph
;) GROUP BY loan_info.id ORDER BY loan_info.loan_number ASC Maybe I'm doing something wrong there? -Dan Joseph > -Original Message- > From: Marek Kilimajer [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 22, 2003 11:25 AM > To: Dan Joseph > Cc: [EMAIL PROTECTED]

Re: [PHP] Array Sorting, 2 items...

2003-07-22 Thread Marek Kilimajer
Your array seems like a result of mysql_fetch_array(), cannot you order it in the sql query? Dan Joseph wrote: Array ( [0] => Array ( [0] => CHECKING [ba_type] => CHECKING [1] => 10132200 [loan_number] => 10132200 Keep e

Re: [PHP] Array Sorting

2003-06-19 Thread Ashley M. Kirchner
Marek Kilimajer wrote: BTW, this is what I always receive when mailing you: Diagnostic-Code: SMTP; 554 5.7.1 Original message rejected due to high SPAM score: 97.4 Hrm, yes. Has to do with your .sk domain I'm sure. Bloody automatic filters. Thanks for the function, it works as expected

Re: [PHP] Array Sorting

2003-06-19 Thread Marek Kilimajer
BTW, this is what I always receive when mailing you: Final-Recipient: RFC822; [EMAIL PROTECTED] Action: failed Status: 5.7.1 Remote-MTA: DNS; serpico.pcraft.com Diagnostic-Code: SMTP; 554 5.7.1 Original message rejected due to high SPAM score: 97.4 Last-Attempt-Date: Thu, 19 Jun 2003 11:36:23 +02

Re: [PHP] Array Sorting

2003-06-19 Thread Marek Kilimajer
Yes, simply don't return 0 when the manufacturers are equal, but continue with other checks: function cmp ($a, $b) { if ($a['cat'] == $b['cat']) { // return 0; -- not anymore, but go on to compare manuf. if ($a['manufacturer'] == $b['manufacturer']) { if ($a['titl

Re: [PHP] Array Sorting

2003-06-19 Thread Ashley M. Kirchner
Marek Kilimajer wrote: Use usort. This function should do the work: Hey thanks! That worked like a charm, once I figured out that making the comparison < instead of > I would get an ascending sort instead of the descending one. Now, can I do multiple sorts? Like, sort on "cat" first, "man

Re: [PHP] Array Sorting

2003-06-19 Thread Marek Kilimajer
Use usort. This function should do the work: function cmp ($a, $b) { if ($a['manufacturer'] == $b['manufacturer']) return 0; return ($a['manufacturer'] > $b['manufacturer']) ? -1 : 1; } Ashley M. Kirchner wrote: I have an array that looks like this: $i = 0; $item[$i] = array( 'link'