3v4l.org

run code in 300+ PHP versions simultaneously
<?php $country_ids = range(1,5); $result['fields'][0]['field_type'] = "countries"; foreach ($country_ids as $id) { $result['fields'][0]['field_value'][] = ["country_id" => $id, "match_type" => "exact"]; } var_export($result); echo "\n---\n"; echo json_encode($result, JSON_PRETTY_PRINT); // this resembles your posted data

preferences:
24.52 ms | 402 KiB | 5 Q