- array_map: documentation ( source)
- json_encode: documentation ( source)
<?php
$urls = [
'https://google.com/',
'https://bing.com/'
];
$names = [
'Google',
'Bing'
];
$combined = array_map(
fn($url, $name) => ['url' => $domain, 'name' => $name],
$urls,
$names
);
echo(json_encode($combined));