How Compare two collections
I need to compare all records
$user1 = User2::all();
$user2 = User1::all();
how comapre the attributes?
How to compare two collections, including the ordering of the collection?
@dirksamson This compares two collections, including the ordering
$original = collect([1, 2, 3]);
$original->sort()->zip($original)->contains(fn(Collection $dates) => $dates->duplicates()->isEmpty()); // false
$original = collect([1, 3, 1]);
$original->sort()->zip($original)->contains(fn(Collection $dates) => $dates->duplicates()->isEmpty()); // true
Please or to participate in this conversation.