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 :: foreach date php 
Php :: laravel vue 
Php :: foreach loop in laravel 
Php :: laravel blank page 
Php :: drupal 8 user_load 
Php :: php filter array 
Php :: php - How do I calculate the percentage of a number? 
Php :: php function crop image 
Php :: get site url 
Php :: currency format in laravel 
Php :: why session is not working in laravel 
Php :: Laravel How do I get distinct values from the table along with the count of how many rows there are containing that value 
Php :: wordpress image size name 
Php :: php sodium extension xampp 
Php :: remove special characters in php 
Php :: Entity of type "DoctrineCommonCollectionsArrayCollection" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager? 
Php :: wordpress display menu by name 
Php :: laravel mail send to multiple recipients 
Php :: what does defined do in php 
Php :: wp_localize_script 
Php :: laravel parent child relationship in same table 
Php :: group where conditions in laravel 
Php :: how to install laravel 
Php :: remove last comma from string php foreach 
Php :: limit text length in php 
Php :: gettype() function in PHP 
Php :: phpunit test private function 
Php :: php clear post data 
Php :: give @s potion off weekness 
Php :: phpexcel set row height 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =