Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$keys = ['name', 'email'];
$data = [
'name' => 'John Brown',
'email' => 'john.b@mail.com',
'tel' => '+123345678'
];
$res = array_filter(
$data,
fn($k) => in_array($k, $keys),
ARRAY_FILTER_USE_KEY
);
print_r($res);