This is the post fields of a CURL request. I need to add multiple county ids to this CURLOPT_POSTFIELDS: -
CURLOPT_POSTFIELDS => '{
"fields": [
{
"field_type": "countries",
"field_value":[
{
"country_id": '.$id.' ,
"match_type": "exact"
}
]
}
]
}'
I have an array of country ids and need to create this block for all: -
{
"country_id": '.$id.' ,
"match_type": "exact"
}
so that If I have 5 country id's it should look like
CURLOPT_POSTFIELDS => '{
"fields": [
{
"field_type": "countries",
"field_value":[
{
"country_id": '.$id[0].' ,
"match_type": "exact"
},
{
"country_id": '.$id[1].' ,
"match_type": "exact"
},
{
"country_id": '.$id[2].' ,
"match_type": "exact"
},
{
"country_id": '.$id[3].' ,
"match_type": "exact"
},
{
"country_id": '.$id[4].' ,
"match_type": "exact"
}
]
}
]
}'
The number of countries may vary each time. So I need to use a for loop inside this to do it dynamically. Thanks in Advance