Joining with comma seperation
Posted: Mon Apr 14, 2008 8:58 pm
I am trying to display list of items only they are available. If the variables are blank, I get
How can I get the value only if it exists?, , ,
Code: Select all
if ($row['type'] == service) {
echo 'service request';
} else {
echo $row['type'];
}
// incident
if ($row['break'] == yes) {
$break = 'Break & Enter';
} else {
$break = '';
}
if ($row['medical'] == yes) {
$medical = 'Medical Emergency';
} else {
$medical = '';
}
if ($row['assault'] == yes) {
$assault = 'Assault';
} else {
$assault = '';
}
if ($row['claim'] == yes) {
$claim = 'Insurance Claim';
} else {
$claim = '';
}
$incident = array($break, $medical, $assault, $claim);
$incident_comma = join(", ", $incident);
echo $incident_comma;