I want to show used components in a line; I have this code
if ($d1>0) {
$d1line="D1 Single Wing Door";
}
else {
$d1line="";
}
if ($d2>0) {
$d2line="D2 Double Wing Door";
}
else {
$d2line="";
}
if ($d1e>0) {
$d1eline="Panic Exit for D1";
}
else {
$d1eline="";
}
if ($d2e>0) {
$d2eline="Panic Exit for D2";
}
else {
$d2eline="";
}
if ($d3>0) {
$d3line="D3 Single Wing Sliding Door";
}
else {
$d3line="";
}
if ($d5>0) {
$d5line="D5 Double Wing Sliding Door";
}
else {
$d5line="";
}
if ($d7>0) {
$d7line="D7 Single Wing, Side Sliding Door";
}
else {
$d7line="";
}
if ($w1>0) {
$w1line="W1 Sliding Window with Screen";
}
else {
$w1line="";
}
if ($hpd1>0) {
$hpd1line="Hydraulic Pump for D1";
}
else {
$hpd1line="";
}
if ($hpd2>0) {
$hpd2line="Hydraulic Pump for D2";
}
else {
$hpd2line="";
}
$accessories=$d1line.", ".$d2line.", ".$d1eline." ".$d2eline.", ".$d3line.", ".$d5line.", ".$d7line." ".$w1line.", ".$hpd1line.", ".$hpd2line;
if ( $accessories[0] == "," ) $accessories = substr($accessories, 1);
...
<p>
<?="$accessories"?>
</p>
is there any way how to format it nicely - so if some/all of them selected they are divided by a comma, if none is selected don't show any commas, etc.
if ($d1>0) {
$d1line="D1 Single Wing Door";
}
else {
$d1line="";
}
if ($d2>0) {
$d2line="D2 Double Wing Door";
}
else {
$d2line="";
}
if ($d1e>0) {
$d1eline="Panic Exit for D1";
}
else {
$d1eline="";
}
if ($d2e>0) {
$d2eline="Panic Exit for D2";
}
else {
$d2eline="";
}
if ($d3>0) {
$d3line="D3 Single Wing Sliding Door";
}
else {
$d3line="";
}
if ($d5>0) {
$d5line="D5 Double Wing Sliding Door";
}
else {
$d5line="";
}
if ($d7>0) {
$d7line="D7 Single Wing, Side Sliding Door";
}
else {
$d7line="";
}
if ($w1>0) {
$w1line="W1 Sliding Window with Screen";
}
else {
$w1line="";
}
if ($hpd1>0) {
$hpd1line="Hydraulic Pump for D1";
}
else {
$hpd1line="";
}
if ($hpd2>0) {
$hpd2line="Hydraulic Pump for D2";
}
else {
$hpd2line="";
}
$accessories=$d1line.", ".$d2line.", ".$d1eline." ".$d2eline.", ".$d3line.", ".$d5line.", ".$d7line." ".$w1line.", ".$hpd1line.", ".$hpd2line;
if ( $accessories[0] == "," ) $accessories = substr($accessories, 1);
...
<p>
<?="$accessories"?>
</p>
is there any way how to format it nicely - so if some/all of them selected they are divided by a comma, if none is selected don't show any commas, etc.