On Wed, July 18, 2007 7:24 am, Olav Mørkrid wrote: > consider the following statement: > > $language = > isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && > $_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? > $_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; You can do it nicely in 2: $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : ''; if ($language == '') $language = '*'; > when using strings in arrays that may be non-existing or empty, you > have to repeat the reference *three* times, which gets excessive and > unreadable. > > is there any way to only have to write > $_SERVER["HTTP_ACCEPT_LANGUAGE"] only once? Not for this, I don't think... PHP 6 or 5.3 might have something where you could do: (expression) ? : ''; And the result of (expression) would be the implied result between ? : But you have a different test (isset) from the result (actual value) so that won't help. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php