I have two arrays, both have the same keys (different values) however array #2 is in a different order. I want to be able to resort the second array so it is in the same ord
You can use array_replace
$arr1 = [ 'x' => '42', 'y' => '551', 'a' => '512', 'b' => 'gge', ]; $arr2 = [ 'a' => 'ordered', 'x' => 'this', 'y' => 'is', 'b' => 'now', ]; $arr2 = array_replace($arr1, $arr2);
$arr2 is now
$arr2
[ 'x' => this, 'y' => is, 'a' => ordered, 'b' => now, ]