This is my problem:
I need to get four members of an array that have the maximum values of an attribute. I have seen the max() function already, but that one only gets me one member, and I need four. For example, I can have an array like this:
array(
array(
"1",
"10"
),
array(
"9",
"10"
),
array(
"3",
"10"
),
array(
"4",
"10"
),
array(
"10",
"10"
),
array(
"8",
"10"
),
array(
"7",
"10"
),
array(
"6",
"10"
),
array(
"5",
"10"
),
array(
"9",
"10"
)
)
I need a function that will get me these four members:
array(“10”, “10”), array(“9”, “10”), array(“8”, “10”), array(“7”,
“10”)
Can anyone help?
Sort the array via usort() in descending order.
Pick the first four items via array_slice
prints