Posts Tagged ‘Languages’

List the languages of each countries

October 18, 2010 Leave a comment

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.


  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

$myfile = ‘languages.txt’;
$lines = file($myfile);

$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.

Categories: Web Services Tags:
%d bloggers like this: