Sort the array with same element at same index PHP

So I have two arrays with some ids. I want to sort the arrays in a way that same value elements in array2 must be at the same index as in array1.
For example:

array1 = ['b','a','c','d'];
array2 = ['d','a','c','b'];

After the sort array2 should become like array1 => ['b','a','c','d']
Is there any function in Php? Thanks in advance 🙂