<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://restcountries.eu/rest/v2/all?',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
//echo $response;
$arr = json_decode($response);
?>
<select class="form-control" id="Country">
<option>Select Country</option>
<?php
$i=0;
while($i!=sizeof($arr))
{
?>
<option value="<?php echo $arr[$i]->callingCodes[0];?>"><?php echo $arr[$i]->name;?></option>
<?php
$i=$i+1;
}
?>
</select>
php use BrightNucleusCountryCodesCountry; // Get the name from an ISO 3166 country code. $name = Country::getNameFromCode( 'US' ); // Returns 'United States'. // Get the ISO 3166 country code from a country name. $code = Country::getCodeFromName( 'United States' ); // Returns 'US