我如何比較兩個數組在php中?我應該如何比較兩個數組?
$arr1[0] = ['user_id' => 1, 'username' => 'bob'];
$arr1[1] = ['user_id' => 2, 'username' => 'tom'];
//and
$arr2[0] = ['user_id' => 2, 'username' => 'tom'];
$arr2[1] = ['user_id' => 3, 'username' => 'john'];
$arr2[2] = ['user_id' => 21, 'username' => 'taisha'];
$arr2[3] = ['user_id' => 1, 'username' => 'bob'];
我需要返回不含加倍數組:
$result[0] = ['user_id' => 3, 'username' => 'john'];
$result[1] = ['user_id' => 21, 'username' => 'taisha'];
你需要編寫一個函數來完成它。沒有簡單的預先寫好的方法。 – ChrisG