Home > Web Services > List the languages of each countries

List the languages of each countries


Below is a list of actions that I have took to extract the languages of each countries. I am sharing the procedure so If you can suggest some optimal procedure to carry out the same task.

Steps:

  1. Visit the CIA world fact book page as mentioned above
  2. Copy that html code while holds the required data using Firebug
  3. Browse the file and copy the fields using pointer
  4. Paste the fields in the text file named languages.txt
  5. Learn how to read the file line by line from php manual
  6. Apply the following PHP script to filter out the data in terms of Country and Native languages

<?php
$myfile = ‘languages.txt’;
$lines = file($myfile);
for($i=count($lines);$i>0;$i–){

$arr = explode(‘ ‘, $lines[$i], 2); // Seperate Country and Native languages
$native = $arr[1]; // Only native languages sperated by “,”
echo “<pre>”;
echo $arr[0];
print_r(explode(‘,’, $native));
echo “</pre>”;
}
?>

What’s left:
Populating the database with the above extracted data.

Advertisements
Categories: Web Services Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: