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] => Hav
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] => Havaian
array_multisort accepts column arrays but here you try to sort row based
arrays.
try this:
$b[self::$sortMember];
}
}
ArrayUtility::sortByMember($array, 'quantity');
?>
Am 25.04.2007, 12:36 Uhr, schrieb Frank Arensmeier
<[EMAIL PROTECTED]>:
Jon, I would suggest that you should have
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:
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( $orig
> 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;
}
i
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] => Arr
www.php.net/usort - slight modification of the example (hint: add [0] to
$a and $b).
Jiří Němec wrote:
hello,
i have got a problem, tehere is an array:
$x = array(
array(15,55,array(1,2,3),3,5,array(1,2,5)),
array(25,55,array(1,2,3),3,5,array(1,2,5)),
array(5,55,array(1,2,3),3,5,array
8 matches
Mail list logo