How to simplify php code that checks for null and sets value to replace null? -
i have write lot of code this:
if ( !empty($value['fax'])) { $temp['fax'] = $value['fax']; } else { $temp['fax'] = "unknown"; } just wondering if there's shorter version of ...
use ternary operators:
$temp['fax'] = !empty($value['fax']) ? $value['fax'] : 'unknown'
Comments
Post a Comment