Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有 2 个数组。
array1: value = 2 value = 1 value = 3 array2: value = 1 value = 2 value = 3 value = 4
我想重新排列 array1 以使 array2 具有相同的排序并删除在 array2 中找不到的值。我想按照array2的排序我不知道是否有一个现有的函数如果有请告诉我。谢谢你。
$array1 = array(2,1,3); $array2 = array(1,2,3,4); $array_intersect = array_intersect($a2, $a1);
$array_intersect然后将有:
$array_intersect
Array ( [0] => 1 [1] => 2 [2] => 3 )