I am having one array like this,
array[0][0],[1][0],[2][0] are questions and array[0][1],[1][1],[2][1] are the answers to that questions.
Now i want to sort this array with respect to number of answers.
1st Ques having only one answer and
2nd having two answer and 3rd having three answer.
The sorted array should be in descending order with respect to number of answers to that question.
Is there anyway to achieve this in sql? Or how Can we sort in php? Hope my question is clear. Thank you in advance.
Array
(
[0] => Array
(
[0] => Array
(
[0] => 12
[1] => 110
[2] => Tom
[3] => Tom@gmail.com
[4] => Hello tom how are you?
[5] => 2013-01-03 14:54:07
)
[1] => Array
(
[0] => Array
(
[0] => 12
[1] => Yes i am fine.
[2] => Arun
[3] => arun@gmail.com
[4] => 2013-01-03 14:55:22
)
)
)
[1] => Array
(
[0] => Array
(
[0] => 12
[1] => 110
[2] => Tom
[3] => Tom@gmail.com
[4] => Hello tom how are you.
[5] => 2013-01-03 14:54:07
)
[1] => Array
(
[0] => Array
(
[0] => 12
[1] => Yes i am fine
[2] => Arun
[3] => arun@gmail.com
[4] => 2013-01-03 14:55:22
)
[1] => Array
(
[0] => 12
[1] => Yes i am fine
[2] => Arun
[3] => arun@gmail.com
[4] => 2013-01-03 14:55:22
)
)
)
[2] => Array
(
[0] => Array
(
[0] => 12
[1] => 110
[2] => Tom
[3] => Tom@gmail.com
[4] => Hello tom how are you.
[5] => 2013-01-03 14:54:07
)
[1] => Array
(
[0] => Array
(
[0] => 12
[1] => Yes i am fine
[2] => Arun
[3] => arun@gmail.com
[4] => 2013-01-03 14:55:22
)
[1] => Array
(
[0] => 12
[1] => Yes i am fine
[2] => Arun
[3] => arun@gmail.com
[4] => 2013-01-03 14:55:22
)
[2] => Array
(
[0] => 12
[1] => Yes i am fine
[2] => Arun
[3] => arun@gmail.com
[4] => 2013-01-03 14:55:22
)
)
)
This should work:
Or if you are using
PHP 5.3.0or greater, you can use: