Sort array by keys of another array.

Posted by marbrun on Stack Overflow See other posts from Stack Overflow or by marbrun
Published on 2010-04-21T17:13:08Z Indexed on 2010/04/21 17:23 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

Hello

There are 2 arrays, both with the same length and with the same keys:

$a1 = [1=>2000,65=>1354,103=>1787];
$a2 = [1=>'hello',65=>'hi',103=>'goodevening'];

asort($a1);

The keys of a1 and a2 are id's from a database.

a1 gets sorted by value. Once sorted, how can we use the same sorting order in a2?

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about sort