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