darkfreaks Posted June 24, 2011 Share Posted June 24, 2011 how would i write a function that would not show certain values if left empty? IE name: joe sex : age: would just display name:Joe instead of name:Joe Sex: age: Link to comment https://forums.phpfreaks.com/topic/240268-function-help/ Share on other sites More sharing options...
wildteen88 Posted June 24, 2011 Share Posted June 24, 2011 Use an if statement to see if there is a value for sex and age // sample data to work with $data['name'] = 'Joe'; $data['sex'] = ''; $data['age'] = ''; echo 'Name: ' . $data['name'] . '<br />'; // Display the sex if its not empty if(!empty($data['name'])) { echo 'Sex: '. $data['sex'] . '<br />'; } // Display the age if its not empty if(!empty($data['age'])) { echo 'Age: '. $data['age'] . '<br />'; } Link to comment https://forums.phpfreaks.com/topic/240268-function-help/#findComment-1234435 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.