<?php
$books_sorted = [
["title" => "In Search of Lost Time", 'others' => 'unuseful1'],
["title" => "Don Quixote", 'others' => 'unuseful2'],
["title" => "The Great Gatsby", 'others' => 'unuseful3']
];
$books_available = [
["title" => "Moby Dick", 'others' => 'unuseful4'],
["title" => "In Search of Lost Time", 'others' => 'unuseful5'],
["title" => "The Great Gatsby", 'others' => 'unuseful6'],
["title" => "War and Peace", 'others' => 'unuseful7']
];
var_export(
array_merge(
array_uintersect(
$books_sorted,
$books_available,
fn($a, $b) => $a['title'] <=> $b['title']
),
array_udiff(
$books_available,
$books_sorted,
fn($a, $b) => $a['title'] <=> $b['title']
),
)
);
preferences:
90.34 ms | 407 KiB | 5 Q