On 17 Dec 2011, at 13:27, Marc Guay wrote: > Just forwarding Carlos' response to the list... > > > ---------- Forwarded message ---------- > From: Carlos Sura <carlos.sura1@xxxxxxxxxxxxxx> > Date: 17 December 2011 01:15 > Subject: Re: dealing with this code $_POST['custom´] > To: Marc Guay <marc.guay@xxxxxxxxx> > > > > > On 16 December 2011 15:57, Marc Guay <marc.guay@xxxxxxxxx> wrote: >> >>> $saving_list = $_POST['custom'] == 'FR' ? 148 : 147; >> >> Hi there, here's a quick translatation of this code that might help >> you understand it better: >> >> if ($_POST['custom'] == 'FR'){ >> $saving_list = 148; >> } >> else{ >> $saving_list = 147; >> } > > > > Hello, > > Thank you both for answer me. > > Also I would like to thank you Marc Guay, because with your answer I > figured out how to do it. > > My code is like this: > > //$saving_list = $_POST['custom'] == 'FR' ? 148 : 147; > if ($_POST['custom'] == 'FR'){ > $saving_list = 148; > } > if ($_POST['custom'] == 'EN'){ > $saving_list = 147; > } > else{ > $saving_list = 152; > } > > I'm not sure if that's the best way, but it is working for me as I > expected, althought any other recommendation would be great. In that case you haven't tested FR yet. FR will set it to 152, not 148. Try this... if ($_POST['custom'] == 'FR') { $saving_list = 148; } elseif ($_POST['custom'] == 'EN') { $saving_list = 147; } else { $saving_list = 152; } Personally I'd recommend a switch for this type of logic... switch ($_POST['custom']) { case 'FR': $saving_list = 148; break; case 'EN': $saving_list = 147; break; default: $saving_list = 152; } However, given the simplicity of what you're doing, an array would be a lot more efficient... $saving_list_options = array( 'FR' => 148, 'EN' => 147, ); $saving_list = isset($saving_list_options[$_POST['custom']]) ? $saving_list_options[$_POST['custom']] : 152; Thinking a little beyond that, is that list of options really hard coded or do they exist elsewhere (e.g. in a database)? If they do then you really should be getting the value from there. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php