Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Get all Country List using php

<?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>
Comment

php get country code from country name

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
Comment

PREVIOUS NEXT
Code Example
Php :: laravel get file to browser send 
Php :: laravel check if collection has value 
Php :: php compare dates 
Php :: how to create php message 3 
Php :: $_server php 
Php :: How to use Query builder with eloquent in Laravel 8? 
Php :: empty in php 
Php :: php echo html and variable 
Php :: encryption and decryption in php example 
Php :: laravel error messages 
Php :: laravel collection get 
Php :: replace last two characters string php 
Php :: how to add two string in php 
Php :: auto refresh extintion php 
Php :: get woocommerce my account page url 
Php :: deprecation notice on phpmyadmin localhost | phpmyadmin deprecation notice 
Php :: get page templete 
Php :: laravel controller middleware example 
Php :: mktime() php 
Php :: php create html code 
Php :: wp php blog info image 
Php :: session array 
Php :: guarded and fillable in laravel 
Php :: php sentense case 
Php :: How to create routes in the codeigniter 
Php :: php file iterator 
Php :: switch case or case php 
Php :: static variable php 
Php :: php $_session err_miss_cache 
Php :: QR code for laravel 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =