In my PHP file I have 2 arrays, in each one the keys are numbered from 0 to its last index, and they both contains the same array elements number, as they are containing data on the same contact, but each array contains a different data about the same contact, and each contact has an ID which is his index on the array.
I have sorted the first array descending according to the values, so the keys are in different sort, and the values are descending. I want to sort the second array, in the same way, so they would have the same keys order, and then to do array_values on both of the arrays, in order it to have new ascending keys order.
For example I have these 2 arrays:
$arr1 = array('0' => 'John', '1' => 'George', '2' => 'James', '3' => 'Harry');
$arr2 = array('0' => '12', '1' => '8', '2' => '34', '3' => '23');
I have sorted $arr2 descending according to his values like this:
arsort($arr2);
// So now, $arr2 is "[2] => '34', [3] => '23', [0] => '12', [1] => '8'"
I want to sort $arr1 in the same way so it will also be:
$arr1 = array('2' => '34', [3] => '23', [0] => '12', [1] => '8');
How can I do this so the arrays will be sorted in the same keys order?
$arr1 = array('2' => '34', [3] => '23', [0] => '12', [1] => '8');, but I don't think that's actually the casearray(4) { [2]=> string(5) "James" [3]=> string(5) "Harry" [0]=> string(4) "John" [1]=> string(6) "George" }, he didn't change the values.