Well this is the first time actually creating a regex.
It works, but was wondering if the regex was created properly.

HTTP_ACCEPT_LANGUAGE is 'en-us, en;q=0.75, nl;q=0.50, fr;q=0.25'

/* Explode the browser report to get each language */
$foo = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] );

/* Perform a regex to get the first 2 letters for each language reported */
foreach ($foo as $bar) {
    $string = 
preg_replace("/([a-z]{2})|(-[a-z]{2})|(;q=[0-9]\.[0-9]{2})/i", "$1", 
trim($bar));
    $array[] = $string;
}

Thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to