php - sort an array by key to match another array's order by key

后端 未结 5 1643
别跟我提以往
别跟我提以往 2020-12-16 01:20

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

5条回答
  •  [愿得一人]
    2020-12-16 01:46

    foreach(array_keys($array1) as $key)
    {
      $tempArray[$key] = $array2[$key];
    }
    $array2 = $tempArray;
    

提交回复
热议问题