Hi,
In order to facilitate multiple countries, each country will have a website URL as below:
http://www.somewhere.com/ie/index.html (for Ireland)
http://www.somewhere.com/fr/index.html (for France)
I'm trying to extract the 2 character country code between the forwardslashes (it will always be 2 characters long). I'm guessing I need a Regexp but I have no idea how to use them.
In English, the pattern would be /XX/ where XX is what needs to be stored in a PHP variable. The position of the string /XX/ would not be fixed as I need this working using
http://localhost/folder as well as
http://server/folder and
http://www........
Can somebody please provide some direction on how I can get started?
Thanks in advance
<?php
$string = "http://www.somewhere.com/ie/index.html";
$resultArray = explode("/",$string,5);
$countryCode = $resultArray[3];
echo "Country Code is " . $countryCode;
?>