PHP ternary function with an IF and OR statement -
can use ternary function replace code?
if (isset($_post['something']) || ($_post['something']=="")){ $a= "n/a"; else{ $a= $_post['something']; } i trying it's not working...
$a = (isset($_post['something']) || ($_post['something']=="")) ? $_post['something'] : 'n/a'; i sending form field can empty , want replace n/a or 'no aplica' spanish when user leave field blank.
this should it.
$a = (!empty($_post['something'])) ? $_post['something'] : 'n/a';
Comments
Post a Comment