Re: [PHP] sorting multi-dimensional arrays

2004-01-16 Thread Mike Migurski
>I've read the manual several times on sorting multi-dimensional arrays, >but I can't seem to wrap my mind around what I need to do to accomplish >my goal. > >//this is what I'm doing: (stepping through a result set, and putting it >into a multi-dimensional array. > >while ($row = mysql_fetch_array

RE: [PHP] sorting multi-dimensional arrays

2003-12-22 Thread Phil Ewington - 43 Plc
Ooops, forgot to specify the compare function with usort(); all working now. Phil. -Original Message- From: Phil Ewington - 43 Plc [mailto:[EMAIL PROTECTED] Sent: 22 December 2003 14:08 To: [EMAIL PROTECTED] Subject: [PHP] sorting multi-dimensional arrays Hi All, I am trying to sort a

RE: [PHP] Sorting Multi-Dimensional Arrays using uksort()

2002-04-01 Thread Bloom, Chris
Sweet! Thanks for the help! -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Monday, April 01, 2002 7:15 PM To: 'Bloom, Chris'; '[EMAIL PROTECTED]' Subject: RE: [PHP] Sorting Multi-Dimensional Arrays using uksort() try using usort() inst

RE: [PHP] Sorting Multi-Dimensional Arrays using uksort()

2002-04-01 Thread Martin Towell
try using usort() instead of uksort() - (i haven't checked the manual but) I believe uksort is for sorting based on the keys and not the values, which is what you're trying to do -Original Message- From: Bloom, Chris [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 02, 2002 9:57 AM To: '[E

Re: [PHP] sorting multi-dimensional arrays

2001-09-16 Thread Christian Dechery
it was just a typo... I meant: $categories[0]["id"]=2; $categories[0]["name"]="lele"; $categories[1]["id"]=6; $categories[1]["name"]="lala"; .. ... and so on... At 00:52 16/9/2001 -0400, you wrote: >The below code would result in an array of: > >$categories[0]["id"]=2; >$categories[0]["name"]=

Re: [PHP] sorting multi-dimensional arrays

2001-04-14 Thread Plutarck
The easiest way is probably to just use a for loop. For instance (no pun intended...well, maybe just a little one): $imax = sizeof($joke); for ($i = 0; $i < $imax; $i++) { if (sizeof($joke[$i]) > 1) { sort($joke[$i]); } } That will handle the sorting of any two-dimensional

Re: [PHP] sorting multi-dimensional arrays

2001-04-14 Thread Delbono
hh, no, maybe the samplecode I posted it's not your case, sorry... > I have a question about sorting multidimensional arrays. Here is my problem: > > I have an 2-d array: > $joke[1][rating]=10; > $joke[2][rating]=20; > $joke[3][rating]=15; > > > I would like to sort the jokes into an

Re: [PHP] sorting multi-dimensional arrays

2001-04-14 Thread Delbono
Try this (it should work): while(list($k, $v) = each($myarray)){ $myarray[$k] = (int) $v; } arsort($myarray); reset($myarray); while(list($k, $v) = each($myarray)){ echo $k, ' == ', $v, "\n; } For better comprehension look at this post: >Hey guys.. > >I have this array that looks like thi