Codice PHP:
<?php
function ModifyString($string, $newLang)
{
$strings = explode("/", $string);
$result = "";
for($i = 0; $i < count($strings); $i++)
{
if($i == 1)
{
$result .= $newLang . "/";
}
else
{
$result .= $strings[$i] . "/";
}
}
return $result;
}
$url = "www.miosito.com/it/percorso/file.php";
$lang = "en";
echo ModifyString($url, $lang);
?>