Page 1 of 1

Help in array sorting problem.

Posted: Tue Oct 07, 2008 5:07 pm
by lovelyThumbsUp
:?: :?: :?: :?:
First of all, thanks for everyone willing to helps me out~!

OK here is my question:

I got three arrays (listed below), I am tried to find a way out to sort these arrays by "clipa", "clipb", "clipc", "clipd", which means, if I choose "clipa", all the arrays with "clipa =>1" will go on top of the array( some resort here) and print out in priority.


For example:

choosed: clipa

out print:

1) id = 0060
2) id = 0062
3) id = 0061


choosed: clipc

out print:


1) id = 0060
2) id = 0061
3) id = 0062


-----------------------------------------------------------------
Array 1
(
[id] => 0060
[content] => Array
(
[clipa] => 1
[clipb] =>
[clipc] => 1
)

)


Array 2
(
[id] => 0061
[content] => Array
(
[clipa] =>
[clipb] => 1
[clipc] => 1
)

)

Array 3
(
[id] => 0062
[content] => Array
(
[clipa] => 1
[clipb] =>
[clipc] =>
)

)

---------------------------------------------------------------

Is there anyone have any idea how to do this? Or which way should I looking into?

Thanks Thanks Thanks

L

Re: Help in array sorting problem.

Posted: Tue Oct 07, 2008 5:13 pm
by VladSun
Write your own compare function and use
http://bg2.php.net/manual/en/function.usort.php

Re: Help in array sorting problem.

Posted: Wed Oct 08, 2008 9:56 am
by lovelyThumbsUp
VladSun wrote:Write your own compare function and use
http://bg2.php.net/manual/en/function.usort.php
Thanks VladSun, I finally got it.