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:
- Visit the CIA world fact book page as mentioned above
- Copy that html code while holds the required data using Firebug
- Browse the file and copy the fields using pointer
- Paste the fields in the text file named languages.txt
- Learn how to read the file line by line from php manual
- 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.
Categories: Web Services
Languages
Recent Comments