On 06/15/2012 06:44 PM, April Mains wrote: > Ah yes that's it. > > Thank you for your help. Have a good weekend. > > April > > On 2012-06-15, at 4:29 PM, Joshua Kehn wrote: > >> Way easier to just use a map. >> >> $mapping = array( >> 'Calgary' => "abc@emailaddress", >> 'Brooks' => "def@emailaddress", >> // etc >> ); >> $toaddress = $mapping[$city]; >> >> Regards, >> >> –Josh >> ____________________________________ >> Joshua Kehn | @joshkehn >> http://joshuakehn.com >> >> On Jun 15, 2012, at 6:20 PM, April Mains wrote: >> >>> I have 25 cities and am currently using the following to set the $toaddress for submitting student pre-registration forms based on the city selected: >>> >>> if ($city == "Calgary") { >>> $toaddress = "abc@emailaddress"; >>> } elseif ($city == "Brooks") { >>> $toaddress = "def@emailaddress"; >>> >>> and so on. >>> >>> >>> Would using switch statements like the following make any appreciable difference? >>> >>> switch ($city) { >>> case"Calgary": >>> $toaddress = "abc@emailaddress"; >>> break; >>> case"Brooks": >>> $toaddress = "def@emailaddress"; >>> break; >>> >>> and so on. >>> >>> Is there a more elegant solution? >>> >>> Thank you for your help, >>> >>> April >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> > If a database solution isn't desired, check out the parse_ini_file() function. You can create a simple INI file containing the necessary mappings and, instead of having to touch the code every time you need to update a record, you simply modify the INI file. Another solution would be to use Joshua's suggestion but instead of managing the array in the PHP file using that array, throw the array in a separate PHP file and simply require_once() it. Of course, these solutions assume that the PHP script reading the INI file or including the PHP that contains the array has the appropriate file permissions to do so. Just my two cents :) - James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php