开发者

array sorting, but keeping other in sync

I have an array, like below. The fact is that $array[0][0] and $array[1][0] are connected. And should stay together.

But I would like to order on the $array[1] values.

$array[0][0] = '567';
$array[0][1] = '3971';
$array[0][2]  = '19';
$array[0][3] = '1';

$array[1][0]  = '10';
$array[1][1] = '50';
$array[1][2]  = '80';
$array[1][3] = '30';

So $array[1][2] = '80'; is the highest and should go to the top, but $array[0][2] 开发者_如何学C= '19'; should move along in his own array.

How do I accomplish this?


Use array_multisort.

array_multisort($array[0], $array[1]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜