>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
Hi All,
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_arra
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
Hi All,
I am trying to sort a multi-dimensional array using a value in the second
dimension. I have looked at the usort examples but don't fully understand
what usort is actually doing so am struggling. I have tried the following:
if (! getmxrr($this->_Domain, $as_hosts, $ai_weights))
{
r
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
9:57 AM
To: '[EMAIL PROTECTED]'
Cc: Bloom, Chris
Subject: [PHP] Sorting Multi-Dimensional Arrays using uksort()
Hey folks:
I have a function that returns an array. I'm assigning the returned array to
a variable inside another function:
--
$dirs = getFileArra
Hey folks:
I have a function that returns an array. I'm assigning the returned array to
a variable inside another function:
--
$dirs = getFileArray($parentDir,"title_2.txt");
--
If I use print_r() on the variable it writes out as expected:
--
Array
(
[0] => Array
eb Application Security - www.whitecrown.net
>*/
>
>- Original Message -----
>From: "Christian Dechery" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Sunday, September 09, 2001 11:51 PM
>Subject: [PHP] sorting multi-dimensional arrays
>
>
&g
I'm having a little trouble sorting mult-dimensional arrays by key...
I looked-up the manual and found out that array_multisort() thing... but I
don't think it does what I want... or I don't understand it...
I have an array like this...
$categories=array();
$categories[0]["id"]=1;
$categories[
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
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
ails, the following 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;
}
- Original Message -
From: <[EMAIL PROTECTED]>
To: &
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 array based on the rating from highest
to lowest. The end result would be something like t
13 matches
Mail list logo