$html = new simple_html_dom();
$html->load_file('https://yandex.ru/web-maps/covid19');
$json = $html->find('script.config-view', 0)->innertext;
$data = json_decode($json, true);
$russian = array_filter(
$data['covidData']['items'],
function ($el) {
return isset($el['ru']) && $el['ru'];
}
);
print_r($russian);
// Array (
// [181] => Array (
// [name] => Алтайский край
// [ru] => 1
// [cases] => 621
// [cured] => 164
// [deaths] => 3
// ...
{ 1: { id: 1, name: 'Pizza', cost: 3}, 2: { ... }, 3: { ... } }
const goodsObj = {}
goods.forEach(el => { goodsObj[el.id] = el })
// {
// 1: { id: "1", name: "Pizza", cost: 3 }
// 2: { id: "2", name: "Cola", cost: 5 }
// 3: { id: "3", name: "Tomatoes", cost: 6 }
// }
Тем более, что id могут идти не по порядку, например вам придёт id 1, 2, 3, 5, 10. header('Location: http://www.example.com/');
Если добавить второй параметр '&', то получаем $info_date вместо $date и $new, равную пустой строке.