Re: [PHP] else if vs switch

2012-06-18 Thread Ashley Sheridan
April Mains wrote: > >On 2012-06-18, at 7:59 AM, James wrote: > >>> Original Message >>> From: April Mains >>> To: >>> Cc: "PHP-General list" >>> Sent: Mon, Jun 18, 2012, 9:41 AM >>> Subject: Re: [PHP] else

Re: [PHP] else if vs switch

2012-06-18 Thread April Mains
On 2012-06-18, at 7:59 AM, James wrote: >> Original Message >> From: April Mains >> To: >> Cc: "PHP-General list" >> Sent: Mon, Jun 18, 2012, 9:41 AM >> Subject: Re: [PHP] else if vs switch >> >> This is what I had been u

Re: Re: [PHP] else if vs switch

2012-06-18 Thread James
> Original Message >From: April Mains >To: >Cc: "PHP-General list" >Sent: Mon, Jun 18, 2012, 9:41 AM >Subject: Re: [PHP] else if vs switch > >This is what I had been using as the check based on the code that had been >there previously and along wit

Re: [PHP] else if vs switch

2012-06-18 Thread April Mains
This is what I had been using as the check based on the code that had been there previously and along with an email validator that sets $email to "" if the address isn't valid. The purpose of the form is lead generation. The last bit is to prevent spammers from entering urls in the class text box.

Re: [PHP] else if vs switch

2012-06-17 Thread James
Same logical check with my personal preference ;) $toaddress = $mapping['default']; if ( isset($city) && isset($mapping[$city]) ) { ... } -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Jim Lucas wrote: On 6/15/2012 3:29 PM, Joshua Kehn wrote: > Way easier to just use

Re: [PHP] else if vs switch

2012-06-17 Thread Jim Lucas
On 6/15/2012 3:29 PM, Joshua Kehn wrote: Way easier to just use a map. $mapping = array( 'Calgary' => "abc@emailaddress", 'Brooks' => "def@emailaddress", // etc ); $toaddress = $mapping[$city]; I would use this, but add a check to it. $mapping = array( 'default' =>

Re: [PHP] else if vs switch

2012-06-15 Thread James Yerge
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@

Re: [PHP] else if vs switch

2012-06-15 Thread April Mains
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 = $mappin

Re: [PHP] else if vs switch

2012-06-15 Thread Joshua Kehn
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

[PHP] else if vs switch

2012-06-15 Thread April Mains
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. Wo