I\'m building a website that contains users with user profiles. Many of the fields in the profile are optional.
There is an opportunity for a lot of user-generate
I would propose this:
public function nameify($names = null) { if(empty($names)) return null; if(!empty($names['display_name'])) return $names['display_name']; if(!empty($names['first_name'])) { $name = $names['first_name']; if (!empty($names['last_name'])) { $name .= ' ' . $names['last_name']; } return $name; } if(!empty($names['id])) return 'user' . $names['id']; return null; }