Simplifying an associative array()
You can definitely simplify this, as the only part of each element of $langs that changes is the two-letter language code. Something like this would work:

&lt;?php
$langs = array(
    "en",
    "de",
    "fr"
);
$self    = $_SERVER['REQUEST_URI'];
$pattern = "{^.*/}i";
$links   = array();
foreach ($langs as $code) {
    $url  = preg_replace($pattern, "$code/", $self);
    $link = "&lt;li&gt;&lt;a href=\"../$url\"&gt;&lt;img src=\"../img/$code.png\"&gt;&lt;/a&gt;&lt;/li&gt;";
    array_push($links, $link);
}
echo implode($links) . "\n";
?&gt;


You just use a non-associative array and append / or .png where needed; much cleaner.