RE: [PHP] sort multidimensional array?

From: Date: Thu, 29 Mar 2001 09:43:54 +0000
Subject: RE: [PHP] sort multidimensional array?
Groups: php.general 
Request: Send a blank email to php-general+get-46054@lists.php.net to get a copy of this message
Swap your indexes round i.e. $list[$r]["priority"] changes to $list["priority"][$r]; This, $list = array_multisort($list["priority"], SORT_NUMERIC, SORT_DESC); should work ok now. -Stewart. -----Original Message----- From: phpman [mailto:info@graphicon.nu] Sent: 28 March 2001 03:33 To: php-general@lists.php.net Subject: Re: [PHP] sort multidimensional array? I'm still confused. I'm looking to sort the list[$r] part of the array based on what value $list[$r]["priority"] is. What would the function's arguments be? ""Stuart J. Browne"" <stuart@promed.com.au> wrote in message news:99rajk$i0v$1@toye.p.sourceforge.net... > > while ($row = mysql_fetch_array($results)) { > > $tmp = get_item_reorder_priority($row["item_sku"]); > > $list[$r]["priority"] = $tmp[0]; > > $list[$r]["sku"] = $row["item_sku"]; > > $r++; > > } > > > > $list = array_multisort($list["priority"], SORT_NUMERIC, SORT_DESC); > > > > and it returns this error: > > Warning: Argument 1 to array_multisort() is expected to be an array or a > > sort flag in d://www/inventory_specific.phtml on line 109 > > > > function get_item_reorder_priority() returns an array - with $tmp[0] > being > > an integer 1-5 > > $row["item_sku"] is simply a string. > > > Umm, dunno about anybody else but it appears as if you are missing a > dimension.. > > In the array creation: > > $list[$r]["priority"] > > is used.. emphasis on the [$r] part. > > When trying to re-order, you are using just $list["priority"]. missing the > [$r] dimension.. > > bkx > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#46054) next »