[PHP] Sorting Help

2012-04-11 Thread Floyd Resler
I need to sort the following array: { [Smith, Bob]=array(137.5,125.5), [Jones, Robert]=array(132.7,128.2) } The array needs to be sorted by the first number (i.e. 137.5) and then the second in descending order. I looked at array_multisort but couldn't figure out how to make

RE: [PHP] Sorting Help

2012-04-11 Thread admin
-Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=array(137.5,125.5), [Jones, Robert]=array(132.7,128.2) } The array needs

RE: [PHP] Sorting Help

2012-04-11 Thread admin
-Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=array(137.5,125.5), [Jones, Robert]=array(132.7,128.2) } The array needs

Re: [PHP] Sorting Help

2012-04-11 Thread Floyd Resler
On Apr 11, 2012, at 1:11 PM, admin wrote: -Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=array(137.5,125.5

Re: [PHP] Sorting Help

2012-04-11 Thread Stuart Dallas
On 11 Apr 2012, at 16:26, Floyd Resler wrote: I need to sort the following array: { [Smith, Bob]=array(137.5,125.5), [Jones, Robert]=array(132.7,128.2) } The array needs to be sorted by the first number (i.e. 137.5) and then the second in descending order. I looked at

Re: [PHP] Sorting Help

2012-04-11 Thread Bastien
Bastien Koert On 2012-04-11, at 2:18 PM, Floyd Resler fres...@adex-intl.com wrote: On Apr 11, 2012, at 1:11 PM, admin wrote: -Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help

Re: [PHP] Sorting an array

2011-03-01 Thread Jim Lucas
On 2/28/2011 7:52 PM, 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:

[PHP] Sorting an array

2011-02-28 Thread Ron Piggott
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: Array ( [362] = Anointing Oil [249] =

Re: [PHP] Sorting an array

2011-02-28 Thread Simon J Welsh
On 1/03/2011, at 4:52 PM, 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:

[PHP] Sorting an array of sub-arrays based on a sub-array's key

2009-09-06 Thread James Colannino
Hey everyone. I have an array that looks like this: $main_array[0] = array('key1' = 'vala'); $main_array[1] = array('key1' = 'valb'); etc. I want to sort the main array based on the value of key1 for each sub-array. I looked at all the array sorting functions, but unless I misunderstood

Re: [PHP] Sorting an array of sub-arrays based on a sub-array's key

2009-09-06 Thread Eddie Drapkin
On Sun, Sep 6, 2009 at 6:45 PM, James Colanninoja...@colannino.org wrote: Hey everyone.  I have an array that looks like this: $main_array[0] = array('key1' = 'vala'); $main_array[1] = array('key1' = 'valb'); etc. I want to sort the main array based on the value of key1 for each sub-array.

Re: [PHP] Sorting an array of sub-arrays based on a sub-array's key

2009-09-06 Thread James Colannino
Eddie Drapkin wrote: http://us3.php.net/uasort Exactly what I was looking for. Thanks. James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Sorting mySQL query - one order from multiple fields

2009-07-26 Thread George Langley
In case anyone else was wondering, the command to use is COALESCE() as in: $theQuery = mysql_query(select variousFields from theTable where date = '$currDate' ORDER BY COALESCE(rotime2,rotime1,time)); COALESCE() will use one of the variables, being the one it finds a value for first,

[PHP] Sorting mySQL query - one order from multiple fields

2009-06-14 Thread George Langley
Hi all. Am trying to sort baseball games by time, where there can be up to 3 times listed per game. Each game has an original date and time field, plus fields for 2 rain-out dates/times (rodate1 rotime1, rodate2, rotime2), to use if the game gets rained out. Note that rotime1 and rotime2

Re: [PHP] Sorting times (SOLVED)

2009-05-16 Thread German Geek
Just a draft i thought should not go unnoticed on the list :-) just cleaning up. OK, How about a super efficient soln where each string is only converted once and a fast sorting algorithm is used: ?php function time_sort($a, $b) { static $now = time(); if (strtotime($a, $now) ==

Re: [PHP] Sorting times (SOLVED)

2009-02-15 Thread tedd
At 9:31 PM -0600 2/14/09, Shawn McKenzie wrote: Yeah, hif I had known that you wanted a function where you loop through your array twice, that would have done it. Bravo. Shawn: I don't see another way. You go through the array converting string to time (seconds), sort, and then convert

Re: [PHP] Sorting times (SOLVED)

2009-02-15 Thread Shawn McKenzie
tedd wrote: At 9:31 PM -0600 2/14/09, Shawn McKenzie wrote: Yeah, hif I had known that you wanted a function where you loop through your array twice, that would have done it. Bravo. Shawn: I don't see another way. You go through the array converting string to time (seconds), sort, and

[PHP] Sorting times

2009-02-14 Thread tedd
Hi gang: Anyone have/know a routine that will sort an array of times? For example, a function that would take an array like this: time[0] ~ '1:30pm' time[1] ~ '7:30am' time[2] ~ '12:30pm' and order it to: time[0] ~ '7:30am' time[1] ~ '12:30pm' time[2] ~ '1:30pm' Cheers, tedd -- ---

Re: [PHP] Sorting times

2009-02-14 Thread John Corry
1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com On Feb 14, 2009, at 4:07 PM, tedd wrote: Hi gang: Anyone

Re: [PHP] Sorting times

2009-02-14 Thread Shawn McKenzie
John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com On Feb 14, 2009, at 4:07 PM, tedd

Re: [PHP] Sorting times (SOLVED)

2009-02-14 Thread tedd
At 4:15 PM -0500 2/14/09, John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com John: Bingo -- that

Re: [PHP] Sorting times (SOLVED)

2009-02-14 Thread Shawn McKenzie
tedd wrote: At 4:15 PM -0500 2/14/09, John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com John:

[PHP] Sorting Arrays

2008-08-22 Thread Tom Shaw
I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) { [0] = array(48) {

Re: [PHP] Sorting Arrays

2008-08-22 Thread Micah Gersten
I believe you'll need a custom sorting function for this. http://us.php.net/usort Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values.

Re: [PHP] Sorting Arrays

2008-08-22 Thread Ashley Sheridan
Yeah, a bubble sorting algorithm should fix it, as it essentially only a very simple sort required. Ash www.ashleysheridan.co.uk ---BeginMessage--- I believe you'll need a custom sorting function for this. http://us.php.net/usort Thank you, Micah Gersten onShore Networks Internal Developer

Re: [PHP] Sorting Arrays

2008-08-22 Thread Robert Cummings
message attachment, Forwarded message - Re: [PHP] Sorting Arrays Forwarded Message From: Micah Gersten [EMAIL PROTECTED] To: Tom Shaw [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] Sorting Arrays Date: Fri, 22 Aug 2008 14:18:53 -0500 I believe

Re: [PHP] Sorting Arrays

2008-08-22 Thread Micah Gersten
Robert Cummings wrote: On Fri, 2008-08-22 at 21:04 +0100, Ashley Sheridan wrote: Yeah, a bubble sorting algorithm should fix it, as it essentially only a very simple sort required. Why use bubble sort when you can use usort() function with an arbitrary handler? Cheers, Rob.

Re: [PHP] Sorting Arrays

2008-08-22 Thread Jim Lucas
Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) {

Re: [PHP] Sorting files in a directory

2007-08-09 Thread Chad Robinson
Steve Marquez wrote: I know this code does not work, but I was curious if someone can take a look and tell me what is wrong? Thank you so much. Re-indent your code properly. If you do it will look like: ?php $pattern = .html*|.php*; if (is_dir(files/)) { if ($dh = opendir(files/)) {

[PHP] Sorting files in a directory

2007-08-08 Thread Steve Marquez
Greetings, I have some code that opens a directory and displays the files. I want to display the files in Alphabetical order. I know this code does not work, but I was curious if someone can take a look and tell me what is wrong? Thank you so much. form name=select_page method=post action=

Re: [PHP] Sorting files in a directory

2007-08-08 Thread Chris
Steve Marquez wrote: Greetings, I have some code that opens a directory and displays the files. I want to display the files in Alphabetical order. I know this code does not work, but I was curious if someone can take a look and tell me what is wrong? Thank you so much. [ I hope the indenting

Re: [PHP] PHP sorting csv array output

2007-05-15 Thread Anna Vester
Yep, that would be the perfect solution, but, unfortunately, database is not an option for this project. Thanks for looking! I did get a solution though from another list. Here is a working version: http://veanndesign.com/sorting.php compare it to the not working one:

Re: [PHP] PHP sorting csv array output

2007-05-13 Thread Richard Lynch
If you are going to sort it by various fields, I'd just throw it into a database... That said, http://php.net/usort should be able to do whatever you want. On Thu, May 10, 2007 2:18 pm, Anna Vester wrote: Hello all, I have a question concerning .CSV array sorting. I have tried googling for

Re: [PHP] sorting via PHP or MySQL?

2007-05-13 Thread Richard Lynch
On Thu, May 10, 2007 1:00 pm, James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type

[PHP] sorting via PHP or MySQL?

2007-05-10 Thread James Tu
(I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type| Null | Key | Default | Extra

RE: [PHP] sorting via PHP or MySQL?

2007-05-10 Thread Brad Fuller
James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ Field| Type| Null | Key | Default

Re: [PHP] sorting via PHP or MySQL?

2007-05-10 Thread Robert Cummings
On Thu, 2007-05-10 at 14:00 -0400, James Tu wrote: (I've cross posted at the MySQL list as well) Here's an example with a simple table: describe collection; +--+-+--+- +-++ | Field| Type

[PHP] PHP sorting csv array output

2007-05-10 Thread Anna Vester
Hello all, I have a question concerning .CSV array sorting. I have tried googling for an answer and have tried different techniques, but nothing seems to works as I would like it to work. Here is my situation: Test file is located here: http://veanndesign.com/test.php I would like to be able to

Re: [PHP] PHP sorting csv array output

2007-05-10 Thread Daniel Brown
One place to start reading, Anna, would be the PHP manual for the fgetcsv() function, which is specifically for CSV parsing. http://www.php.net/fgetcsv On 5/10/07, Anna Vester [EMAIL PROTECTED] wrote: Hello all, I have a question concerning .CSV array sorting. I have tried googling for

Re: [PHP] PHP sorting csv array output

2007-05-10 Thread Anna Vester
On 5/10/07, Daniel Brown [EMAIL PROTECTED] wrote: One place to start reading, Anna, would be the PHP manual for the fgetcsv() function, which is specifically for CSV parsing. http://www.php.net/fgetcsv Thanks for your quick reply Daniel. Yes I've seen that function before and i am

Re: [PHP] PHP sorting csv array output

2007-05-10 Thread tg-php
When you load your data into your array, you can use the timezone (or whatever field you're using to sort) as the array key, then use ksort(). Check the see also for a bunch of other types of sorting you can do. When it comes to the multisorts and user defined sorts, I'm at a bit of a

Re: [PHP] sorting via PHP or MySQL?

2007-05-10 Thread Larry Garfield
A somewhat more extensible version of the 1 query method: http://www.garfieldtech.com/blog/php-group-by If you will only ever have 2 values there, then either method is probably fine. The php group by method (above) is more extensible if you're going to have a variable or arbitrary number of

[PHP] sorting multi array

2007-04-25 Thread Jon Bennett
hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top Pink Crystal [size] = 5 (37/38) [quantity] = 4 ) [3388] = Array ( [name] = Havaianas Brazil Silver

Re: [PHP] sorting multi array

2007-04-25 Thread Frank Arensmeier
Jon, I would suggest that you should have a look at the function array_multisort. See the manual for details on what this function is capable of. //frank 25 apr 2007 kl. 01.58 skrev Jon Bennett: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array

RE: [PHP] sorting multi array

2007-04-25 Thread Chris Boget
I have the following array, which I need to sort by quantity... I need to keep the indexes if poss. This may not be the most elegant solution. Let's call your array $origArray $tmpArray = array(); foreach( $origArray as $elKey = $elArray ) { $tmpArray[$elArray['quantity']] = $elKey; } if(

RE: [PHP] sorting multi array

2007-04-25 Thread Zoltán Németh
2007. 04. 25, szerda keltezéssel 11.39-kor Chris Boget ezt írta: I have the following array, which I need to sort by quantity... I need to keep the indexes if poss. This may not be the most elegant solution. Let's call your array $origArray $tmpArray = array(); foreach( $origArray as

Re: [PHP] sorting multi array

2007-04-25 Thread Chris Boget
this won't work if he has the same quantity for several keys, I think Yes, you are correct. If that is the case, then you would just need to change the following line $tmpArray[$elArray['quantity']] = $elKey; to $tmpArray[$elArray['quantity']][] = $elKey; then change logic in this loop:

Re: [PHP] sorting multi array

2007-04-25 Thread [EMAIL PROTECTED]
array_multisort accepts column arrays but here you try to sort row based arrays. try this: ? class ArrayUtility { /* Sorts an array by a member */ static private $sortMember; static function sortByMember($array, $member) { self::$sortMember = $member;

Re: [PHP] sorting multi array

2007-04-25 Thread Myron Turner
Jon Bennett wrote: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top Pink Crystal [size] = 5 (37/38) [quantity] = 4 ) [3388] = Array ( [name] = Havaianas

Re: [PHP] sorting multi array

2007-04-25 Thread Richard Lynch
Search the archives for multisort array and you should find this thread a few thousand times... On Tue, April 24, 2007 6:58 pm, Jon Bennett wrote: hi, I have the following array, which I need to sort by quantity... Array ( [2408] = Array ( [name] = Havaianas Top

[PHP] Sorting a multidimensional array

2007-02-08 Thread Dave Goodchild
Hi all. I am building an online events directory and as part of the system users can search for events by date, category etc. The logic involved in finding events that match the user-entered dates works like so: 1. we create a range of dates from the start and end dates specified by the user 2.

Re: [PHP] Sorting a multidimensional array

2007-02-08 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-02-08 14:08:13 +: Hi all. I am building an online events directory and as part of the system users can search for events by date, category etc. The logic involved in finding events that match the user-entered dates works like so: 1. we create a range of

Re: [PHP] Sorting a multidimensional array

2007-02-08 Thread Dave Goodchild
Thanks for that - can't do that as all I know in the database is the start and end date for each event (so I don't have to create mapping tables and perform massive joins), the rest is handle dynamically. I think I can do it using usort, this seems to work, any comments? function compare($x,

Re: [PHP] Sorting a multidimensional array

2007-02-08 Thread Németh Zoltán
array_multisort? http://php.net/manual/en/function.array-multisort.php hope that helps Zoltán Németh On cs, 2007-02-08 at 14:08 +, Dave Goodchild wrote: Hi all. I am building an online events directory and as part of the system users can search for events by date, category etc. The

RE: [PHP] Sorting a multidimensional array

2007-02-08 Thread Edward Kay
How about this: http://uk.php.net/manual/en/function.array-multisort.php#53779 Edward -Original Message- From: Dave Goodchild [mailto:[EMAIL PROTECTED] Sent: 08 February 2007 14:30 To: Roman Neuhauser Cc: php-general@lists.php.net Subject: Re: [PHP] Sorting a multidimensional array

Re: [PHP] Sorting issue

2007-02-08 Thread tg-php
Paul's probably right.. putting the sorting values in a table would be eaiser to maintain. I don't know what I was thinking with the whole then you don't HAVE to create a table. Both ways work.. but especially if you think the positions may change, then it'll be tons easier to update if

[PHP] Sorting issue

2007-02-07 Thread Don
I have been trying to figure out how to get this to work for a couple of days. I need to sort the results of a DB query based on the hierarchy of positions within an organization. Since they are not necessarily alphabetical, the best I can come up with is to assign a numerical value in a

Re: [PHP] Sorting issue

2007-02-07 Thread tg-php
Well, kind of ugly but you can do something like this: SELECT Position, CASE Position WHEN 'CEO' THEN 1 WHEN 'COO' THEN 2 WHEN 'CFO' THEN 3 WHEN 'HR' THEN 4 ELSE 99 END AS PositionSort FROM SomeTable ORDER BY PositionSort That way you're not creating a whole new table to store the sorting

Re: [PHP] Sorting issue

2007-02-07 Thread Paul Novitski
= = = Original message = = = I need to sort the results of a DB query based on the hierarchy of positions within an organization. Since they are not necessarily alphabetical, the best I can come up with is to assign a numerical value in a separate table to each position, and reference that to

[PHP] Sorting multidimensional arrays

2006-11-16 Thread Dave Goodchild
Hi all. I have a multidimensional array here: array(6) { [0]= array(25) { [0]= string(1) 7 [eventid]= string(1) 7 [1]= string(2) 17 [cat_id]= string(2) 17 [2]= string(13) Tits And Bums [name]= string(13) Tits And Bums [3]= string(19) The Pleasure Centre [venue]= string(19) The Pleasure Centre

Re: [PHP] Sorting multidimensional arrays

2006-11-16 Thread Robert Cummings
On Thu, 2006-11-16 at 15:28 +, Dave Goodchild wrote: Hi all. I have a multidimensional array here: Bums [name]= string(13) Tits And Bums [3]= string(19) The Pleasure [--SNIP--] ...which comprises a set of returned results for an events search - with the date computed dynamically and

Re: [PHP] Sorting multidimensional arrays

2006-11-16 Thread Dave Goodchild
Result. Cheers! On 11/16/06, Robert Cummings [EMAIL PROTECTED] wrote: On Thu, 2006-11-16 at 15:28 +, Dave Goodchild wrote: Hi all. I have a multidimensional array here: Bums [name]= string(13) Tits And Bums [3]= string(19) The Pleasure [--SNIP--] ...which comprises a set of returned

Re: [PHP] Sorting MySQL queries

2006-11-07 Thread Dotan Cohen
On 07/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: you really need to deal with this issue at the database design/data entry level. doing things on the sort to exclude (otherwise undefined) initial articles (as some have suggested) is very maintenance heavy as you have to update the sort

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread tedd
At 3:13 PM +0200 11/5/06, Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically with SQL's ORDER BY ASC argument, however, if there is a

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Curt Zirzow
On 11/5/06, Roman Neuhauser [EMAIL PROTECTED] wrote: If you used PostgreSQL I'd suggest a functional index and ordering on the function... Does MySQL have anything like this? CREATE FUNCTION fn(TEXT) RETURNS TEXT IMMUTABLE STRICT LANGUAGE SQL AS $$ SELECT

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Richard Lynch
On Sun, November 5, 2006 7:13 am, Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically with SQL's ORDER BY ASC argument, however, if there is

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Dotan Cohen
On 06/11/06, Richard Lynch [EMAIL PROTECTED] wrote: On Sun, November 5, 2006 7:13 am, Dotan Cohen wrote: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically

Re: [PHP] Sorting MySQL queries

2006-11-06 Thread Børge Holen
On Monday 06 November 2006 08:15, clive wrote: Current code: $query = SELECT subject FROM table ORDER BY subject asc; $result = mysql_query($query); I dont seen any php code to do any sorting,just a mysql query, perhaps a mysql list or maybe you should try doing it in php yourself first.

[PHP] Sorting MySQL queries

2006-11-05 Thread Dotan Cohen
I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically with SQL's ORDER BY ASC argument, however, if there is a preceding the or a then that is considered as part

Re: [PHP] Sorting MySQL queries

2006-11-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-11-05 15:13:19 +0200: I have a list of subjects, such as Linux, Open Source, and the World Wide Web. The subjects are stored in a database and being retrieved via php. I currently organize them alphabetically with SQL's ORDER BY ASC argument, however, if there is a

Re: [PHP] Sorting MySQL queries

2006-11-05 Thread clive
Current code: $query = SELECT subject FROM table ORDER BY subject asc; $result = mysql_query($query); I dont seen any php code to do any sorting,just a mysql query, perhaps a mysql list or maybe you should try doing it in php yourself first. Not that I know the answer, but mysql does have

Re: [PHP] Sorting Multidimensional Array

2006-10-31 Thread Richard Lynch
On Tue, October 31, 2006 11:10 am, Keith Spiller wrote: RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow; } The purpose is to retrieve the table data and

Re: [PHP] Sorting Multidimensional Array

2006-10-31 Thread Keith Spiller
Subject: Re: [PHP] Sorting Multidimensional Array On Tue, October 31, 2006 11:10 am, Keith Spiller wrote: RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow

[PHP] Sorting Multidimensional Array

2006-10-31 Thread Keith Spiller
Hi, RE: Sorting Multidimensional Array I'm trying to sort a multidimensional array. The data was taken from a mysql query: $myrow = mysql_fetch_row($result) { query[] = $myrow; } The purpose is to retrieve the table data and manually add a record, then sort ASC by the startdate which is

[PHP] sorting array after array_count_values

2006-08-15 Thread afan
hi to all! I have an array of products $products $products = array_count_values($products); now I have an array where $key is product number and $value is how many times I have such a product in the array. I want to sort this new array that product with the most duplicates are on the first place,

Re: [PHP] sorting array after array_count_values

2006-08-15 Thread Richard Lynch
On Tue, August 15, 2006 9:01 am, [EMAIL PROTECTED] wrote: I have an array of products $products $products = array_count_values($products); now I have an array where $key is product number and $value is how many times I have such a product in the array. I want to sort this new array that

Re: [PHP] sorting in array

2006-08-03 Thread Richard Lynch
; } -Original Message- From: weetat [mailto:[EMAIL PROTECTED] Sent: Monday, July 31, 2006 12:32 PM To: php-general@lists.php.net Subject: [PHP] sorting in array Hi all , I have array value as shown below, i have paste my test php code below: I have problem when doing usort() when 'country

Re: [PHP] sorting in array

2006-07-31 Thread weetat
Message- From: weetat [mailto:[EMAIL PROTECTED] Sent: Monday, July 31, 2006 12:32 PM To: php-general@lists.php.net Subject: [PHP] sorting in array Hi all , I have array value as shown below, i have paste my test php code below: I have problem when doing usort() when 'country' = '', i would

Re: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 10:31 PM 7/30/2006, weetat wrote: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do that ? ... $arraytest= array( array ( 'country' = '', ) , array (

RE: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 05:40 PM 7/30/2006, Peter Lauri wrote: function cmpcountry($a, $b) { $country1 = $a['country']; $country2 = $b['country']; if($country1=='') return 1; else return ($country1 $country2) ? -1 : 1; } Good call, Peter; my suggestion was

RE: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 12:22 AM 7/31/2006, Paul Novitski wrote: I could make that last statement just a bit simpler: function cmpcountry($a, $b) { $country1 = ($a['country'] == '') ? zzz : $a['country']; $country2 = ($b['country'] == '') ? zzz : $b['country']; return ($country1

Re: [PHP] sorting in array

2006-07-31 Thread weetat
Thanks Paul, Very weird tried Peter's option, it doesn't work. Btw , how to sort by ascending ? Thanks Paul Novitski wrote: At 12:22 AM 7/31/2006, Paul Novitski wrote: I could make that last statement just a bit simpler: function cmpcountry($a, $b) { $country1 =

Re: [PHP] sorting in array

2006-07-31 Thread Paul Novitski
At 01:14 AM 7/31/2006, weetat wrote: Thanks Paul, Very weird tried Peter's option, it doesn't work. Btw , how to sort by ascending ? Please explain what you mean. The current script DOES sort ascending by country (except for the blank country fields which are placed at the end):

RE: [PHP] sorting in array

2006-07-31 Thread Peter Lauri
: Re: [PHP] sorting in array Thanks Paul, Very weird tried Peter's option, it doesn't work. Btw , how to sort by ascending ? Thanks Paul Novitski wrote: At 12:22 AM 7/31/2006, Paul Novitski wrote: I could make that last statement just a bit simpler: function cmpcountry($a, $b

RE: [PHP] sorting in array

2006-07-31 Thread Peter Lauri
@lists.php.net Subject: Re: [PHP] sorting in array At 10:31 PM 7/30/2006, weetat wrote: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do that ? ... $arraytest= array( array

Re: [PHP] sorting in array

2006-07-31 Thread David Tulloh
weetat wrote: Hi all , I have array value as shown below, i have paste my test php code below: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do that ? ... You might try searching the list's archive's.

[PHP] sorting in array

2006-07-30 Thread weetat
Hi all , I have array value as shown below, i have paste my test php code below: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do that ? Thanks $arraytest= array( array ( 'country'

RE: [PHP] sorting in array

2006-07-30 Thread Peter Lauri
31, 2006 12:32 PM To: php-general@lists.php.net Subject: [PHP] sorting in array Hi all , I have array value as shown below, i have paste my test php code below: I have problem when doing usort() when 'country' = '', i would like to display records where country = '' last. Any ideas how to do

[PHP] sorting array question

2006-07-26 Thread Angelo Zanetti
Hi all, Need some advice as to how to sort a array: Structure: partnerID partnerName total totalPaid totalUnpaid So basically there will be many entries for the following: eg: partnerID | partnerName | total | totalPaid | totalUnpaid 1 marc 12 5

Re: [PHP] sorting array question

2006-07-26 Thread John Wells
On 7/26/06, Angelo Zanetti [EMAIL PROTECTED] wrote: Hi all, So they way I want to sort these rows is by total, totalPaid, totalUnpaid all descending. Hi Angelo, So the first question the list will ask is if the array of data is coming from a database. Because then you'd be urged to perform

Re: [PHP] sorting array question

2006-07-26 Thread Angelo Zanetti
hi guys, thanks for the replies! yes Melanie, you were correct the last example (i had an old version of the manual). seemed to do the trick =) Thanks to john as well for the reply. Angelo Melanie Maddix wrote: [snip] So they way I want to sort these rows is by total, totalPaid,

Re: [PHP] sorting troubles

2006-04-25 Thread Richard Lynch
On Sat, April 22, 2006 4:49 am, William Stokes wrote: I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? Like A20 B17 B16 C15

Re: [PHP] sorting troubles

2006-04-25 Thread William Stokes
Thanks for your input everyone! The easiest way to do this was ansding this to the SELECT clause: select col from DB order by substring(col, 1, 1) ASC, substring(col, 2) DESC Seems to work fine. -Will Richard Lynch [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] On Sat, April 22,

Re: [PHP] sorting troubles

2006-04-24 Thread Philip Thompson
On Apr 22, 2006, at 4:49 AM, William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be

Re: [PHP] sorting troubles

2006-04-24 Thread Philip Thompson
On Apr 24, 2006, at 9:06 AM, Philip Thompson wrote: On Apr 22, 2006, at 4:49 AM, William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by

Re: [PHP] sorting troubles

2006-04-23 Thread chris smith
I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? Like A20 B17 B16 C15 C14 D13 D12 Depending on how many records you have

Re: [PHP] sorting troubles

2006-04-23 Thread David Tulloh
William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? PHP has the

[PHP] sorting troubles

2006-04-22 Thread William Stokes
Hello, Any idea how to sort this? I have a column in DB that contains this kind of data, A20,B16,B17C14,C15,D13,D12 etc. I would like to print this data to a page and sort it ascending by the letter an descending by the number. Can this be done? Like A20 B17 B16 C15 C14 D13 D12 Thanks -Will

Re: [PHP] sorting troubles

2006-04-22 Thread Peter Hoskin
See explode, http://www.php.net/explode $var = 'A20,B16,B17C14,C15,D13,D12'; $array = explode(',',$var); foreach ($array as $key = $value) { echo $value .\n; } William Stokes wrote: Hello, Any idea how to sort this? I have a column in DB that contains this kind of data,

Re: [PHP] sorting troubles

2006-04-22 Thread Peter Hoskin
hmm, should also see http://www.php.net/sort Peter Hoskin wrote: See explode, http://www.php.net/explode $var = 'A20,B16,B17C14,C15,D13,D12'; $array = explode(',',$var); foreach ($array as $key = $value) { echo $value .\n; } William Stokes wrote: Hello, Any idea how to sort

  1   2   3   4   >