Re: [PHP] Sort question..

2012-04-25 Thread Matijn Woudt
On Wed, Apr 25, 2012 at 3:16 PM, Karl-Arne Gjersøyen wrote: > Hello again. > I have a photo album that show all images in a specified directory. > but I like to sort them by filename as one possibillity and random > sort the photos as another feature. > I don't know how to do this.. Here is my sor

[PHP] Sort question..

2012-04-25 Thread Karl-Arne Gjersøyen
Hello again. I have a photo album that show all images in a specified directory. but I like to sort them by filename as one possibillity and random sort the photos as another feature. I don't know how to do this.. Here is my soruce-code: Bildegalleri

Re: [PHP] Sort problem

2011-09-14 Thread Igor Escobar
Wow! Thank you! I completely forgot this method! Regards, Igor Escobar *Software Engineer * + http://blog.igorescobar.com + http://www.igorescobar.com + @igorescobar On Wed, Sep 14, 2011 at 12:02 PM, Marc Guay wrote: > > Anyone know a smart way to orde

Re: [PHP] Sort problem

2011-09-14 Thread Marc Guay
> Anyone know a smart way to order file names? Nope, but I know a "natural" way: http://ca.php.net/manual/en/function.natsort.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Sort problem

2011-09-14 Thread Igor Escobar
Hi Folks! Anyone know a smart way to order file names? An example to you guys picture what im saying is: The result of this snippet is: Array ( [0] => Two And Half Man Season 1[1] => Two And Half Man Season 10[2] => Two And Half Man Season 2 [3] => Two And Half Man Season 3

Re: [PHP] Sort two coupled arrays [my solution]

2010-04-09 Thread Robert Cummings
tedd wrote: Rob: You're never confused because you are always right. I should have you mention this to my wife... I'll provide the helmet >:) Congrats, you were the first to solve this problem this simply. To tell the truth, I didn't fully understand how array_multisort() worked until I re

Re: [PHP] Sort two coupled arrays [my solution]

2010-04-09 Thread tedd
At 10:26 AM -0400 4/8/10, Robert Cummings wrote: tedd wrote: At 8:28 AM -0400 4/8/10, Andrew Ballard wrote: On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun wrote: > rsort(array_combine(array2, array1)); you should expect array( 'Personal Email' => 75, 'USPS mail' => 40, 'Personal Phone' =

Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread Robert Cummings
tedd wrote: At 8:28 AM -0400 4/8/10, Andrew Ballard wrote: On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun wrote: > rsort(array_combine(array2, array1)); you should expect array( 'Personal Email' => 75, 'USPS mail' => 40, 'Personal Phone' => 31, 'Web site' => 31, 'Text Message' => 31

Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread Andrew Ballard
On Thu, Apr 8, 2010 at 9:55 AM, tedd wrote: > At 8:28 AM -0400 4/8/10, Andrew Ballard wrote: >> >> On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun wrote: >> >>  > >>> >>>  rsort(array_combine(array2, array1)); >>> >>>  you should expect array( >>>  'Personal Email' => 75, >>>  'USPS mail' => 40, >>>  'P

Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread tedd
At 8:28 AM -0400 4/8/10, Andrew Ballard wrote: On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun wrote: > rsort(array_combine(array2, array1)); you should expect array( 'Personal Email' => 75, 'USPS mail' => 40, 'Personal Phone' => 31, 'Web site' => 31, 'Text Message' => 31 ) logically

Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread tedd
At 6:46 PM -0400 4/7/10, Ryan Sun wrote: rsort(array_combine(array2, array1)); you should expect array( 'Personal Email' => 75, 'USPS mail' => 40, 'Personal Phone' => 31, 'Web site' => 31, 'Text Message' => 31 ) logically, the items are your key but not the count of votes Logically

Re: [PHP] Sort two coupled arrays {my solution]

2010-04-08 Thread Andrew Ballard
On Wed, Apr 7, 2010 at 6:46 PM, Ryan Sun wrote: > On Wed, Apr 7, 2010 at 6:29 PM, tedd wrote: [snip] >> >> Let's look at the problem again (a vote collection problem): >> >> Array 1 >> ( >>    [1] => 75 >>    [2] => 31 >>    [3] => 31 >>    [4] => 31 >>    [5] => 40 >> ) >> >> Array 1 is an arr

Re: [PHP] Sort two coupled arrays {my solution]

2010-04-07 Thread Ryan Sun
rsort(array_combine(array2, array1)); you should expect array( 'Personal Email' => 75, 'USPS mail' => 40, 'Personal Phone' => 31, 'Web site' => 31, 'Text Message' => 31 ) logically, the items are your key but not the count of votes On Wed, Apr 7, 2010 at 6:29 PM, tedd wrote: > At 5:3

Re: [PHP] Sort two coupled arrays {my solution]

2010-04-07 Thread tedd
At 5:35 PM -0400 4/7/10, Andrew Ballard wrote: On Wed, Apr 7, 2010 at 5:02 PM, Paul M Foster wrote: Array indexes have to be unique regardless of whether they are numeric or strings. Ahhh, so you start to see the problem, eh? Let's look at the problem again (a vote collection problem): Array

Re: [PHP] Sort two coupled arrays

2010-04-07 Thread Hans Åhlin
Try this insted array( [0]=>array( [0]=>75, [1] => Personal Email) [1]=>array( [0]=>31, [1] => Personal Phone) [2]=>array( [0]=>31, [1] => Web site) [3]=>array( [0]=>31, [1] => Text Message) [4]=>array( [0]=>40, [1] => USPS mail) MvH / Hans Åhlin Tel: +46761488019 http://www.kronan-net.com/ irc:/

Re: [PHP] Sort two coupled arrays

2010-04-07 Thread Andrew Ballard
On Wed, Apr 7, 2010 at 5:02 PM, Paul M Foster wrote: > On Wed, Apr 07, 2010 at 04:09:47PM -0400, tedd wrote: > >> Hi gang: >> >> Here's the problem -- I want to sort and combine two arrays into one >> sorted array. Here's a real-world example: >> >> Array 1 >> ( >>     [1] => 75 >>     [2] => 31 >

Re: [PHP] Sort two coupled arrays

2010-04-07 Thread Paul M Foster
On Wed, Apr 07, 2010 at 04:09:47PM -0400, tedd wrote: > Hi gang: > > Here's the problem -- I want to sort and combine two arrays into one > sorted array. Here's a real-world example: > > Array 1 > ( > [1] => 75 > [2] => 31 > [3] => 31 > [4] => 31 > [5] => 40 > ) > > Array 2 > (

Re: [PHP] Sort two coupled arrays

2010-04-07 Thread Mattias Thorslund
Piero Steinger wrote: Am 07.04.2010 22:09, schrieb tedd: Hi gang: Here's the problem -- I want to sort and combine two arrays into one sorted array. Here's a real-world example: Array 1 ( [1] => 75 [2] => 31 [3] => 31 [4] => 31 [5] => 40 ) Array 2 ( [1] => Personal

Re: [PHP] Sort two coupled arrays

2010-04-07 Thread Piero Steinger
Am 07.04.2010 22:09, schrieb tedd: > Hi gang: > > Here's the problem -- I want to sort and combine two arrays into one > sorted array. Here's a real-world example: > > Array 1 > ( > [1] => 75 > [2] => 31 > [3] => 31 > [4] => 31 > [5] => 40 > ) > > Array 2 > ( > [1] => Person

[PHP] Sort two coupled arrays

2010-04-07 Thread tedd
Hi gang: Here's the problem -- I want to sort and combine two arrays into one sorted array. Here's a real-world example: Array 1 ( [1] => 75 [2] => 31 [3] => 31 [4] => 31 [5] => 40 ) Array 2 ( [1] => Personal Email [2] => Personal Phone [3] => Web site [4]

Re: [PHP] Sort a multi-dimensional array on a certain key followed by another key

2009-03-28 Thread Virgilio Quilario
> Ok so, I have an array > > [0(index)][1st key][2nd key] > > Basically I don't care about the index. As a matter of fact I'd prefer it > reset to still be in order afterwards. > > However, I need to sort the 1st key and keep correlation w the second key. > Then sort on the second key. > > I have v

Re: [PHP] Sort a multi-dimensional array on a certain key followed by another key

2009-03-27 Thread Jim Lucas
TS wrote: Ok so, I have an array [0(index)][1st key][2nd key] Basically I don't care about the index. As a matter of fact I'd prefer it reset to still be in order afterwards. However, I need to sort the 1st key and keep correlation w the second key. Then sort on the second key. I have video v

[PHP] Sort a multi-dimensional array on a certain key followed by another key

2009-03-27 Thread TS
Ok so, I have an array [0(index)][1st key][2nd key] Basically I don't care about the index. As a matter of fact I'd prefer it reset to still be in order afterwards. However, I need to sort the 1st key and keep correlation w the second key. Then sort on the second key. I have video volumes and s

Re: [PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Chris
Verdon Vaillancourt wrote: Hi, I'm running into some sorting issues using a while(list($vars) = mysql_fetch_row($result)). I can provide more code if needed, but thought I would try this little bit first to see if I'm missing a fundamental concept and not a detail. In a nutshell, I have a q

Re: [PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Daniel Brown
On Wed, Feb 27, 2008 at 10:27 AM, Verdon Vaillancourt <[EMAIL PROTECTED]> wrote: > Hi Dan, > > Thanks for the input. The only reason is that I'm inheriting this > from someone else and am asked to do a 'quick' fix to get it working > again. The whole script is a little kludgy and it may be bett

Re: [PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Per Jessen
Verdon Vaillancourt wrote: > Thanks for the input. The only reason is that I'm inheriting this > from someone else and am asked to do a 'quick' fix to get it working > again. The whole script is a little kludgy and it may be better to > redo it. Is there anything fundamentally wrong with the while

Re: [PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Verdon Vaillancourt
On 27-Feb-08, at 9:23 AM, Daniel Brown wrote: On Wed, Feb 27, 2008 at 7:58 AM, Verdon Vaillancourt <[EMAIL PROTECTED]> wrote: [snip!] Then I pass it through this.. while(list($id, $text, $url, $m_order) = mysql_fetch_row($result)) { $out .= "$text - $m_order \n"; } echo $out; Is

Re: [PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Daniel Brown
On Wed, Feb 27, 2008 at 7:58 AM, Verdon Vaillancourt <[EMAIL PROTECTED]> wrote: [snip!] > Then I pass it through this.. > while(list($id, $text, $url, $m_order) = mysql_fetch_row($result)) { >$out .= "$text - $m_order \n"; > } > echo $out; Is there a reason you're not simplifying this

[PHP] sort in while(list($vars) = mysql_fetch_row($result))

2008-02-27 Thread Verdon Vaillancourt
Hi, I'm running into some sorting issues using a while(list($vars) = mysql_fetch_row($result)). I can provide more code if needed, but thought I would try this little bit first to see if I'm missing a fundamental concept and not a detail. In a nutshell, I have a query first.. $result = my

[PHP] Re: SOLVED: [PHP] Sort Array not working

2007-01-09 Thread Kevin Murphy
Once you see it in email, sometimes the obvious jumps out at you. Fixed this on my own. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 On Jan 9, 2007, at 10:41 AM, Kevin Murphy wrote: I'm having trouble sorting an arra

Re: [PHP] Sort Array not working

2007-01-09 Thread Fredrik Thunberg
Hi sort returns a bool, the sorted array passed by reference. So try: $result = sort( $array ); //Now $array is sorted print_r( $array ); /Fredrik Thunberg Kevin Murphy skrev: I'm having trouble sorting an array. When I do, it empties the array for some reason. Take the following code: $d

[PHP] Sort Array not working

2007-01-09 Thread Kevin Murphy
I'm having trouble sorting an array. When I do, it empties the array for some reason. Take the following code: $data = "bird,dog,cat,dog,,horse,bird,bird,bird,lizard"; $array = explode(",",$data); // Create the array $array = array_diff($array, array("")); // Drop the em

Re: [PHP] sort() warning

2006-09-06 Thread Robert Cummings
On Wed, 2006-09-06 at 11:03 -0600, Ashley M. Kirchner wrote: > Robert Cummings wrote: > > It's because you have written sloppy code and didn't bother to > > initialize $Dirs to an array. So it's default value is null. You would > > know this if you had notices enabled. > > > Error fixed. >

Re: [PHP] sort() warning

2006-09-06 Thread Ashley M. Kirchner
Robert Cummings wrote: It's because you have written sloppy code and didn't bother to initialize $Dirs to an array. So it's default value is null. You would know this if you had notices enabled. Error fixed. Also, the other problem is that you are either a) opening the wrong path, b) t

Re: [PHP] sort() warning

2006-09-06 Thread Robert Cummings
On Wed, 2006-09-06 at 10:47 -0600, Ashley M. Kirchner wrote: > Given this piece of code: > > $i = 0; > if ($dir = opendir($path)) { > while ($dh = readdir($dir)) { > if ($dh != '.' && $dh != '..') { > $Dirs[$i] = $dh; > $i++; > } > } > } > closedir($

[PHP] sort() warning

2006-09-06 Thread Ashley M. Kirchner
Given this piece of code: $i = 0; if ($dir = opendir($path)) { while ($dh = readdir($dir)) { if ($dh != '.' && $dh != '..') { $Dirs[$i] = $dh; $i++; } } } closedir($dir); sort($Dirs); Why does sort() give me the following warning: PHP Warning: sort(

Re: [PHP] Sort Array

2006-07-18 Thread Miles Thompson
At 10:51 AM 7/18/2006, weetat wrote: Hi I have the array below : How to sort the array by "Model" and "Country? Thanks array( "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"), "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"), "TBA0123459" => array("Countr

RE: [PHP] Sort Array

2006-07-18 Thread Jay Blanchard
[snip] Jay Blanchard wrote: > [snip] > I have the array below : How to sort the array by "Model" and "Country? > > Thanks > > array( > >"TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"), >"TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"), >"TBA0123459" =>

Re: [PHP] Sort Array

2006-07-18 Thread Jochem Maas
Jay Blanchard wrote: > [snip] > I have the array below : How to sort the array by "Model" and "Country? > > Thanks > > array( > >"TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"), >"TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"), >"TBA0123459" => array("

Re: [PHP] Sort Array

2006-07-18 Thread Andrew Brampton
ECTED]> To: "weetat" <[EMAIL PROTECTED]>; Sent: Tuesday, July 18, 2006 3:17 PM Subject: RE: [PHP] Sort Array [snip] I have the array below : How to sort the array by "Model" and "Country? Thanks array( "TBA0123456" => array("Count

RE: [PHP] Sort Array

2006-07-18 Thread tg-php
Actually it's going to be a little more complicated than a 'ksort' here I think. ksort on the main array is going to give you: array ( "TBA0123451" => array("Country"=>"Germany","Model"=>"WS6234"), "TBA0123452" => array("Country"=>"England","Model"=>"WS1234"), "TBA0123456" => array("Coun

RE: [PHP] Sort Array

2006-07-18 Thread Jay Blanchard
[snip] I have the array below : How to sort the array by "Model" and "Country? Thanks array( "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"), "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"), "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"),

[PHP] Sort Array

2006-07-18 Thread weetat
Hi I have the array below : How to sort the array by "Model" and "Country? Thanks array( "TBA0123456" => array("Country"=>"Singapore","Model"=>"WS8234"), "TBA0123458" => array("Country"=>"Indonesia","Model"=>"WS2234"), "TBA0123459" => array("Country"=>"Vietnam","Model"=>"WS7234"), "TB

RE: [PHP] sort multidimension array

2006-06-22 Thread Ford, Mike
On 22 June 2006 02:22, weetat wrote: > Hi all, > > I have multi-arrays as shown below: > I implemented usort() to sort the array by 'country' field > in the array. > However there some empty string value in the array and i setup my > cmpcountry() function to sort array, however , some count

Re: [PHP] sort multidimension array

2006-06-21 Thread weetat
Hi David , Thanks for your input, it solve my problem. David Tulloh wrote: Examine your function for the case of cmpcountry("Thailand", ""); if($country2 == '') is true if($country1 < $country2) is false Then ($country1 < $country2) is false again and 1 is returned. This means that "" is

Re: [PHP] sort multidimension array

2006-06-21 Thread David Tulloh
Examine your function for the case of cmpcountry("Thailand", ""); if($country2 == '') is true if($country1 < $country2) is false Then ($country1 < $country2) is false again and 1 is returned. This means that "" is less than "Thailand", and should be sorted higher. The easiest way to fix this is

[PHP] sort multidimension array

2006-06-21 Thread weetat
Hi all, I have multi-arrays as shown below: I implemented usort() to sort the array by 'country' field in the array. However there some empty string value in the array and i setup my cmpcountry() function to sort array, however , some country empty string value are sort first . Any ideas w

Re: [PHP] Sort table by column and pagination

2005-08-26 Thread Philip Hallstrom
We have quite a complex product all written in PHP and our own mySQL wrapper. We initially wanted to use smarty, but due to time constraints, we couldn't re-write everything, so it never got implemented. Two feature requests we get a lot are the ability to sort the tabular data by column heading

[PHP] Sort table by column and pagination

2005-08-26 Thread Daevid Vincent
We have quite a complex product all written in PHP and our own mySQL wrapper. We initially wanted to use smarty, but due to time constraints, we couldn't re-write everything, so it never got implemented. Two feature requests we get a lot are the ability to sort the tabular data by column heading (

Re: [PHP] Sort multi array.

2005-08-13 Thread Torgny Bjers
João Cândido de Souza Neto wrote: >I´ve in a array the coluns: date , weekday , hour , etc... > >I need to sort him by coluns 0 and 2 but not found the correctly function to >do it. > Take a look at this manual page: http://www.php.net/manual/en/function.array-multisort.php Regards, Torgny --

[PHP] Sort multi array.

2005-08-13 Thread João Cândido de Souza Neto
I´ve in a array the coluns: date , weekday , hour , etc... I need to sort him by coluns 0 and 2 but not found the correctly function to do it. Please, anyone know how can i do? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] sort by date

2005-05-09 Thread William Stokes
Thanks Richard. That did the trick. Now to the DB fixing business... -Will "Richard Lynch" <[EMAIL PROTECTED]> kirjoitti viestissä:[EMAIL PROTECTED] > On Thu, May 5, 2005 10:42 pm, William Stokes said: >> I made a mistake and stored date information to DB as varchar values >> (dd.mm.yyy). When

Re: [PHP] sort by date

2005-05-08 Thread Richard Lynch
On Thu, May 5, 2005 10:42 pm, William Stokes said: > I made a mistake and stored date information to DB as varchar values > (dd.mm.yyy). When I read the DB is it still possible to sort the data by > date with SQL query (ORDER BY date ASC)? Or is it nessessary to have the > date information to be st

Re: [PHP] sort by date

2005-05-06 Thread eoghan
William Stokes wrote: OK. I found that out from MySQL manual. I just don't know how to insert the date formatting function to the query: I quessI need to put STR_TO_DATE() in to the following SQL query: SELECT event_id,name,date,time,place,type,info FROM test_table WHERE (group = '$group') AND (t

Re: [PHP] sort by date

2005-05-06 Thread Petar Nedyalkov
On Friday 06 May 2005 11:17, William Stokes wrote: > OK. I found that out from MySQL manual. I just don't know how to insert the > date formatting function to the query: > > I quessI need to put STR_TO_DATE() in to the following SQL query: What about DATE_FORMAT()? > > SELECT event_id,name,date,t

Re: [PHP] sort by date

2005-05-06 Thread William Stokes
OK. I found that out from MySQL manual. I just don't know how to insert the date formatting function to the query: I quessI need to put STR_TO_DATE() in to the following SQL query: SELECT event_id,name,date,time,place,type,info FROM test_table WHERE (group = '$group') AND (type = 'Game' OR type

Re: [PHP] sort by date

2005-05-06 Thread Petar Nedyalkov
On Friday 06 May 2005 08:42, William Stokes wrote: > Hello, > > I made a mistake and stored date information to DB as varchar values > (dd.mm.yyy). When I read the DB is it still possible to sort the data by > date with SQL query (ORDER BY date ASC)? Or is it nessessary to have the > date informati

Re: [PHP] sort by date

2005-05-06 Thread Marek Kilimajer
William Stokes wrote: Hello, I made a mistake and stored date information to DB as varchar values (dd.mm.yyy). When I read the DB is it still possible to sort the data by date with SQL query (ORDER BY date ASC)? Or is it nessessary to have the date information to be stored as a date in the DB? W

[PHP] sort by date

2005-05-05 Thread William Stokes
Hello, I made a mistake and stored date information to DB as varchar values (dd.mm.yyy). When I read the DB is it still possible to sort the data by date with SQL query (ORDER BY date ASC)? Or is it nessessary to have the date information to be stored as a date in the DB? Will it work or is the

Re: [PHP] Sort by string length...

2004-12-21 Thread David Otton
On Tue, 21 Dec 2004 16:18:52 -0500 (EST), you wrote: >Any idea how to sort an array by string length? You write a function that compares two strings (A and B), and returns 0 if len(A) == len(B), -1 if len(A) < len(B) or +1 if len(A) > len(B). function compare_by_length ($a, $b) { $la = strle

Re: [PHP] Sort by string length...

2004-12-21 Thread tg-php
Is it an associative array? That is, are you assigning values like this: Method 1: $arr[] = "some text string"; or $arr = array("some text string","some text string too"); or like this... Method 2: $arr["value1"] = "some text string"; or $arr1 = array("value1"=>"some text string","value2"=>"som

Re: [PHP] Sort by string length...

2004-12-21 Thread ApexEleven
How about iterating though the strings and putting string values and lengths in an array: [begin untested code] $strings = array('i','am','who'); $string_count = array(); foreach ($strings as $string) { $string_count['value'][] = $string; $string_count['length'][] = strlen($string); } array_mult

Re: [PHP] Sort by string length...

2004-12-21 Thread Chris
One of the Array sort functions? http://www.php.net/usort Russell P Jones wrote: Any idea how to sort an array by string length? Russ Jones -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Sort by string length...

2004-12-21 Thread Jason Wong
On Wednesday 22 December 2004 05:18, Russell P Jones wrote: > Any idea how to sort an array by string length? usort(), strlen() -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development

Re: [PHP] Sort by string length...

2004-12-21 Thread Tom Rogers
Hi, Wednesday, December 22, 2004, 7:18:52 AM, you wrote: RPJ> Any idea how to sort an array by string length? RPJ> Russ Jones With a user defined sorting function something like this -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.ne

RE: [PHP] Sort by string length...

2004-12-21 Thread Michael Sims
Russell P Jones wrote: > Any idea how to sort an array by string length? Use usort() in conjunction with a user defined function that compares the length of both strings using strlen(). If brevity at the (possible) expense of clarity is your thing, you can even use create_function() as your call

[PHP] Sort by string length...

2004-12-21 Thread Russell P Jones
Any idea how to sort an array by string length? Russ Jones -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Sort $_FILE['userfile']['name'] by ascending abc order...

2004-11-19 Thread Scott Fletcher
Um, let's see, what would be the way to go in sorting the dual array --snip-- $_FILES['userfile']['name'] $_FILES['userfile']['type'] $_FILES['userfile']['size'] $_FILES['userfile']['tmp_name'] $_FILES['userfile']['error'] --snip-- where $_FILES['userfile']['name'] would be in ascending abc orde

Re: [PHP] sort multidim array

2004-10-05 Thread Jasper Howard
This was just discusses in quite some detail. Everyone decieded that usort() was the best and a couple peopel agreed that array_multisory() works just fine. Check out that convo to get some pretty good details on how to do this. On Tue, 05 Oct 2004 13:04:44 -0400, Kevin Coyner <[EMAIL PROTECTED]>

[PHP] sort multidim array

2004-10-05 Thread Kevin Coyner
I've been banging my head against the wall on this one. Probably trivial to the knowledgeable, but I'm stumped despite trying the various sort functions as advertised on php.net. I've got the following fields: retailer city state telephone distance Sample data looks like: BLIND BROOK

[PHP] sort() - Where did I go wrong?

2004-07-10 Thread John Taylor-Johnston
I'm having another problem with sort(); I want to treat $rbenquiry as a string, not as a numeral. $mydata->RB could contain "1.2" ; "1.9" ; "1.1" ; "1.0" ; "1.0.8" But if $rbenquiry ="1.0", my code spits out anything that begins as though it were ="1". It should only display "1.1" or "1.0.8".

Re: [PHP] Sort a text string by last word before separator

2004-06-23 Thread Evan Nemerson
If I were you I'd use preg_match_all() so you get the first and last name as separate elements, then use usort() to create a custom sorting function based on strnatcasecmp() Be careful about middle names and the such. On Thursday 24 Jun 2004 04:38, Andre Dubuc wrote: > Given a text string: > >

Re: [PHP] Sort multidimensional array - ARGH!

2004-02-05 Thread Tom Rogers
Hi, Thursday, February 5, 2004, 11:35:34 PM, you wrote: KS> I have been messing around now for some hours and Im going mad! KS> Im pulling some heavy data from mySQL with count and grouping, KS> after this I have to calculate som values and then sort the outcome. KS> Therefore Im not able to let m

[PHP] Sort multidimensional array - ARGH!

2004-02-05 Thread Kim Steinhaug
I have been messing around now for some hours and Im going mad! Im pulling some heavy data from mySQL with count and grouping, after this I have to calculate som values and then sort the outcome. Therefore Im not able to let mySQL do the accuall sort. So i stuff it into an array, and I need to sor

RE: [PHP] Sort a while loop ?

2004-01-02 Thread Dave Carrera
Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Sort a while loop ? Hi, Saturday, January 3, 2004, 1:12:49 AM, you wrote: DC> Hi List, DC> How can I sort a while loop or do something before it to achieve the DC> following? DC> I have a MySql result fetching something like this: DC> Id

Re: [PHP] Sort a while loop ?

2004-01-02 Thread Tom Rogers
Hi, Saturday, January 3, 2004, 1:12:49 AM, you wrote: DC> Hi List, DC> How can I sort a while loop or do something before it to achieve the DC> following? DC> I have a MySql result fetching something like this: DC> Id Name Number DC> 1 Bob 34567 DC> 2 Ben 234 DC> 3 Jeff 4567 DC> 4 Dave 23

[PHP] Sort a while loop ?

2004-01-02 Thread Dave Carrera
Hi List, How can I sort a while loop or do something before it to achieve the following? I have a MySql result fetching something like this: Id Name Number 1 Bob 34567 2 Ben 234 3 Jeff 4567 4 Dave 2345 But I want to sort the while loop by Number Highest first so the result looks like this

Re: [PHP] Sort flags

2003-12-14 Thread John W. Holmes
Jake McHenry wrote: Hi all, quick question. Whenever I try putting any flags with the any of the sort functions, I get this error: Warning: Wrong parameter count for natsort() in /var/www/secure/travelrequest/handler.php on line 950 My sort call looks like this: natsort($array, "SORT_STRING"); na

[PHP] Sort flags

2003-12-14 Thread Jake McHenry
Hi all, quick question. Whenever I try putting any flags with the any of the sort functions, I get this error: Warning: Wrong parameter count for natsort() in /var/www/secure/travelrequest/handler.php on line 950 My sort call looks like this: natsort($array, "SORT_STRING"); Running PHP v. 4.2

Re: [PHP] Sort Array by date

2003-12-04 Thread Curt Zirzow
* Thus wrote Matt Palermo ([EMAIL PROTECTED]): > I have a bunch of dates in the form: MM-DD- in an array and I want to > sort them and display them in descending order. I have tried the usort() > function below and it's not working. Can anyone help me out here? > > $menu_item = array(); > $m

RE: [PHP] Sort Array by date

2003-12-04 Thread Martin Towell
Hiya, I changed your date_file_sort() function so it echos a few things function date_file_sort($a, $b) { echo "$a - $b - "; $a = strtotime($a); $b = strtotime($b); echo "$a - $b - ".date("d-M-Y", $a)." - ".date("d-M-Y", $b)."\n"; return strcmp($a, $b); } "interesting" result

[PHP] Sort Array by date

2003-12-04 Thread Matt Palermo
I have a bunch of dates in the form: MM-DD- in an array and I want to sort them and display them in descending order. I have tried the usort() function below and it's not working. Can anyone help me out here? $menu_item = array(); $menu_item[] = "12-04-2003"; $menu_item[] = "11-19-2003"; $me

Re: [PHP] Sort an array of objects

2003-10-01 Thread Marek Kilimajer
Matt Palermo wrote: I have an array of object for files on my site. The objects hold a file's name, size, extension, etc... I was wondering if anyone knows where I could find a relatively easy function for sorting the array of these objects by either name, size, etc... Please let me know if got

[PHP] Sort an array of objects

2003-10-01 Thread Matt Palermo
I have an array of object for files on my site. The objects hold a file's name, size, extension, etc... I was wondering if anyone knows where I could find a relatively easy function for sorting the array of these objects by either name, size, etc... Please let me know if got any tips. Thanks a

[PHP] Sort locale problem

2003-06-14 Thread Johan Grönvall
Hi! I'm trying to sort an array with strings containing swedish characters. However, the sort order is wrong. The following code produces "abäåö" while it should be "abåäö". $list = array("ö", "ä", "a","å","b"); setlocale("LC_ALL","se_SE.ISO8859-1"); usort($list, 'strcoll'); for($i=0;$ihttp://w

Re: [PHP] Sort of a multidimensional array

2003-06-11 Thread Armand Turpel
Thanks for your reply. But it is impossible to arrange the array as you suggest, in this case. - Original Message - From: "Chris Hayes" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 11, 2003 11:49 AM Subject: Re: [PHP] Sort of a multidimensional

Re: [PHP] Sort of a multidimensional array

2003-06-11 Thread Chris Hayes
At 11:18 11-6-03, you wrote: Hi, Is there a simple way to sort the following array structure by the array cell 'title'=>'TXx'? $x[0][0] = array(array('id'=>1,'title'=>'TXx'),array('id'=>2,'title'=>'T2')); $x[0][1] = array('id'=>10,'title'=>'Test1'); $x[1][0] = array(array('id'=>3,'title'=>

[PHP] Sort of a multidimensional array

2003-06-11 Thread Armand Turpel
Hi, Is there a simple way to sort the following array structure by the array cell 'title'=>'TXx'? $x[0][0] = array(array('id'=>1,'title'=>'TXx'),array('id'=>2,'title'=>'T2')); $x[0][1] = array('id'=>10,'title'=>'Test1'); $x[1][0] = array(array('id'=>3,'title'=>'TXx'),array('id'=>6,'ti

[PHP] sort mixed array

2003-02-27 Thread Jim Long
Hi, I have an array with an html link as key and different $vars as val: $list = array ( 'http://someplace.com/";>some place' => $vendor1_total, 'http://anotherplace.com/";>another place' => $vendor2__total, [snip] etc.. some vals are numeric and some vals are "n/a" asort works to sort the arra

[PHP] Sort List But NOT After Date Has Passed.

2003-02-01 Thread Randum Ian
Hi guys, I have a script which looks in a directory, pulls out all the files and sorts them by reverse date order. The file name schema is "mmdd-the rest of the file". Script: --- $interestingFile = array(); $interestingFiles = array(); $dir = opendir('/home/danceportal/www/uk/ian') or die(

Re: [PHP] sort dinamic generated table

2002-09-05 Thread Geoff Hankerson
Rodrigo Peres wrote: >Hi, > >I have a resume system that put a rank in it resume at runtime. example: If >you do a serach for each match that it finds it atribute 1 point, now I need >to sort the generated list based in this rank, how can i do this, since this >rank is dinamic and isn't in databa

RE: [PHP] sort dinamic generated table

2002-09-05 Thread David Buerer
stick the values in an array and use asort() to sort it. -Original Message- From: Rodrigo Peres [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 05, 2002 8:30 AM To: PHP Subject: [PHP] sort dinamic generated table Hi, I have a resume system that put a rank in it resume at runtime

[PHP] sort dinamic generated table

2002-09-05 Thread Rodrigo Peres
Hi, I have a resume system that put a rank in it resume at runtime. example: If you do a serach for each match that it finds it atribute 1 point, now I need to sort the generated list based in this rank, how can i do this, since this rank is dinamic and isn't in database?? Thank's -- PHP Gene

Re: [PHP] sort()-help needed

2002-08-20 Thread Jason Wong
On Wednesday 21 August 2002 06:41, Øystein Håland wrote: > "Put them into an array and sort() the array. The loop through the sorted > array and output at that point." > > Just what I try. But, because of my lack of understanding, the output is my > problem: > You're not doing what has been sugg

Re: [PHP] sort()-help needed

2002-08-20 Thread Øystein Håland
"Put them into an array and sort() the array. The loop through the sorted array and output at that point." Just what I try. But, because of my lack of understanding, the output is my problem: function createLinks() { $p = 0; $handle=opendir("."); echo "\n"; while ($file = readdir($handle)){

Re: [PHP] sort()-help needed

2002-08-20 Thread Rasmus Lerdorf
Put them into an array and sort() the array. The loop through the sorted array and output at that point. -Rasmus On Wed, 21 Aug 2002, Øystein Håland wrote: > When calling the function createLinks() I get an unsorted result, and that's > NOT what I want. But I'm not able (lack of knowlegde) to

[PHP] sort()-help needed

2002-08-20 Thread Øystein Håland
When calling the function createLinks() I get an unsorted result, and that's NOT what I want. But I'm not able (lack of knowlegde) to sort the output (the links). \n"; while ($file = readdir($handle)){ if (($file == ".") || ($file == "..") || ($file == "index.php") || ($file == basename ($PHP

[PHP] Sort multidimensional array using Natural-Order

2002-08-18 Thread Hessu
Hi, I have following filename/date array Array ( [0] => Array ( [0] => 1.jpg [1] => 10.jpg [2] => 11.jpg [3] => 12.jpg [4] => 2.jpg [5] => 3.jpg [6] => 4.jpg [7] => 5.jpg [8] => 6.jpg [9] => 7.jpg [10] => 8.jpg [11] => 9.jpg ) [1] => Array ( [0] => 1026502301 [1] => 1026502312 [2] => 1026502313

[PHP] Sort multidimensional array using Natural-Order

2002-08-18 Thread Hessu
Hi, I have following filename/date array Array ( [0] => Array ( [0] => 1.jpg [1] => 10.jpg [2] => 11.jpg [3] => 12.jpg [4] => 2.jpg [5] => 3.jpg [6] => 4.jpg [7] => 5.jpg [8] => 6.jpg [9] => 7.jpg [10] => 8.jpg [11] => 9.jpg ) [1] => Array ( [0] => 1026502301 [1] => 1026502312 [2] => 1026502313 [

[PHP] Sort multidimensional array using Natural-Order

2002-08-18 Thread Hessu
Hi, I have following filename/date array Array ( [0] => Array ( [0] => 1.jpg [1] => 10.jpg [2] => 11.jpg [3] => 12.jpg [4] => 2.jpg [5] => 3.jpg [6] => 4.jpg [7] => 5.jpg [8] => 6.jpg [9] => 7.jpg [10] => 8.jpg [11] => 9.jpg ) [1] => Array ( [0] => 1026502301 [1] => 1026502312 [2] => 1026502313

  1   2   >