How do I check if only 1 individual variable of the array is empty? I would need an element to display or not, depending on if there is content in the variable. Problem is, if I add more than one variable, it hides/shows the element for all, instead of individually. Any help appreciated.
What works:
PHP:
<?php
$texta = CFS()->get( 'sometexta' );
if ($texta !='') {
$display = 'block';
} else {
$display = 'none';
}
?>
HTML:
<div class="element" style="display:<?php echo $display; ?>">
<p><?php echo $texta; ?></p>
</div>
....
What I would like to work:
PHP:
<?php
$texta = CFS()->get( 'sometexta' );
$textb = CFS()->get( 'sometextb' );
$textc = CFS()->get( 'sometextc' );
$alltext = array($texta, $textb, $textc);
foreach ( $alltext as $text) {
if ($text !='') {
$display = 'block';
} else {
$display = 'none';
}
}
?>
HTML:
<div class="element" style="display:<?php echo $display; ?>">
<p><?php echo $texta; ?></p>
</div>
<div class="element" style="display:<?php echo $display; ?>">
<p><?php echo $textb; ?></p>
</div>
<div class="element" style="display:<?php echo $display; ?>">
<p><?php echo $textc; ?></p>
</div>
....