Gerard: On Sat, May 18, 2002 at 12:38:37PM -0400, Gerard Samuel wrote:
> HTTP_ACCEPT_LANGUAGE is 'en-us, en;q=0.75, nl;q=0.50, fr;q=0.25' > > $foo = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); > 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; > } The replacements supposed to be \\1 rather than $1. But, $1 might work anyway. Also, you can just assign the fuction to $array[], rather than assigning it to $string and then $string to $array[]. But, even better, use preg_match_all: http://www.php.net/manual/en/function.preg-match-all.php That'll eliminate the need to split() first. Just put the stuff you want to keep, ie the two lettered language codes, in subpatterns "()" and keep the rest of the stuff out of sub patterns. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php