Subscribe To Our Newsletter

Sign Up Now To Get Free Coupon Codes, Event Coupon Codes Updates, Offers Updates. It's 100% Free!

We Hate Spam! Really, It's terrible and we never do it.

Convert XML to PHP Array | Multilingual + Country wise SEO URL Solution

Multilingual + Country wise SEO URL Solution:

Example
http://www.getacho.com/index.php?loc=pk&lang=en
Here I did deep research that how can I use PHP for Multilingual websites?
But we need to keep in mind some topics like
  1. User IP Address Function
  2. User Language Function
  3. IP to XML
  4. XML to PHP Array Conversion
  5. URL Concept
  6. Language And Area codes concept
If you know these things then, you can use this function easily.

 <?php  
 //Redirect by language  
 $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);  
 $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));  
 //redirect by IP  
 $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];  
 $ip = $_SESSION['ip'];  
 $data = file_get_contents("http://api.hostip.info/get_html.php?ip=".$ip."&position=true");  
 $arrayofdata = explode("\n", $data);  
 $country = explode(":", $arrayofdata[0]);  
 $count = explode(" ", $country[1]);  
 if(!isset($_GET['lang']) AND !isset($_GET['loc']))  
 {  
      //Retrieve location, set time  
      if(empty($count))  
      {  
           header("location: index.php?loc=us-en&lang=".$lang);  
           exit;  
      }  
      else  
      {  
           header("location: index.php?loc=".strtolower(trim($count[2],"()"))."&lang=".$lang);  
           exit;  
      }  
 }  
 ?>  

Share this article :

Post a Comment

Give your reviews about this blog. Leave your comments. what do you think about this post?

Meet Samee Ullah Feroz On Google Plus
Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.

---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards

 
Support : | Internet Marketing Specialist And Business Developer
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger