Replacing smarty variable from an associative array's values

From: Date: Fri, 07 Feb 2003 23:15:07 +0000
Subject: Replacing smarty variable from an associative array's values
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7579@lists.php.net to get a copy of this message
I have a book database and a field called country in my table. Countries are coded with a two letter country code, e.g US, GB etc. I also have a long array of natural names for those codes, saved in a file, like this: $ISO3166_CODE_TO_NATURAL = array( "AF" => "Afghanistan", "AL" => "Albania", "DZ" => "Algeria", "AS" => "American Samoa", "AD" => "Andorra", "AO" => "Angola", "AI" => "Anguilla", "AQ" => "Antarctica", "AG" => "Antigua And Barbuda", "AR" => "Argentina", "AM" => "Armenia", "AW" => "Aruba", "AU" => "Australia", ...etc. Now when I retrieve data for this table and want to display the long name from the arrays, how should I do this without writing 200-300 lines of {if } constructions? Country: {$ISO3166_CODE_TO_NATURAL[{$Country}] }won't work, but what would? thank you

« previous php.smarty.general (#7579) next »