PHP - Conditional for show/hide multiple values

0 votes
189 views
added Sep 24, 2019 in PHP by lcjr First Warrant Officer (11,850 points)
<?php if(
  !(
    empty($profile->field_address_line_1->value()) &&
    empty($profile->field_address_line_2->value()) &&
    empty($profile->field_zip->value()) &&
    empty($profile->field_area->value()) &&
    empty($profile->field_state->value())
  )
): ?>     
<div class="_row">
  <div>
      <i class="fa fa-map-marker" aria-hidden="true"></i>
      <?php if(!empty($profile->field_address_line_1->value())): ?>
        <?php print $profile->field_address_line_1->value(); ?>
      <?php endif;?>
      <?php if(!empty($profile->field_address_line_2->value())): ?>
        <br/>
        <?php print $profile->field_address_line_2->value(); ?>
      <?php endif;?>
      <?php if(!empty($profile->field_zip->value())): ?>
        <br/> Postal Code:
        <?php print $profile->field_zip->value(); ?>
      <?php endif;?>
      <?php if(!empty($profile->field_area->value())): ?>
        <br/>
        <?php print area_id_to_name($profile->field_area->value()); ?>
      <?php endif;?>
      <?php if(!empty($profile->field_state->value())): ?>
        <br/>
        <?php print state_id_to_name($profile->field_state->value()); ?>
      <?php endif;?>
  </div>
</div>
<?php endif;?>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...