FW: [SMARTY] Replacing smarty variable from an associative array's values

From: Date: Sat, 08 Feb 2003 11:51:17 +0000
Subject: FW: [SMARTY] Replacing smarty variable from an associative array's values
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7591@lists.php.net to get a copy of this message
Try constructions like {$assoc_array.$var} or {assoc_array[$var]} {$ISO3166_CODE_TO_NATURAL.$Country} Or {$ISO3166_CODE_TO_NATURAL[$Country]} --------------- Ruslan Savchyshyn http://www.MagneticOne.com/ Web development and design services -----Original Message----- From: gawan [mailto:mail@gawan.net] Sent: Saturday, February 08, 2003 1:15 AM To: smarty-general@lists.php.net Subject: [SMARTY] Replacing smarty variable from an associative array's values 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 -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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