I have the following set of if
statements:
<?php
if (!empty($sn1link) && !empty($sn1)) {
echo('<a href="'.$sn1link.'" target="_blank"><button class="lbutton-content">'.$sn1.'</button></a>');
}
if (!empty($sn2link) && !empty($sn2)) {
echo('<a href="'.$sn2link.'" target="_blank"><button class="lbutton-content">'.$sn2.'</button></a>');
}
if (!empty($sn3link) && !empty($sn3)) {
echo('<a href="'.$sn3link.'" target="_blank"><button class="lbutton-content">'.$sn3.'</button></a>');
}
if (!empty($sn4link) && !empty($sn4)) {
echo('<a href="'.$sn4link.'" target="_blank"><button class="lbutton-content">'.$sn4.'</button></a>');
}
if (!empty($sn5link) && !empty($sn5)) {
echo('<a href="'.$sn5link.'" target="_blank"><button class="lbutton-content">'.$sn5.'</button></a>');
?>
I would like a more elegant way of combining these if
statements. I've tried else if
but obviously this would only display the first if
statement that returns TRUE
whereas I'd like to return every TRUE
statement. I don't think a switch
would work either.