W
W
web-7202022-01-31 19:33:55
PHP
web-720, 2022-01-31 19:33:55

The if else condition does not work. Where is the mistake?

There are no syntax errors. Tell me where am I making a mistake? Tk should, if condition 1 is not active, it should work 2. Does not work.

<?php if (is_array($this->product->extra_field)){?>
<?php foreach($this->product->extra_field as $extra_field){?>
<?php if ($extra_field["id"] == 1){?>
<?php print $extra_field['value'];?>
<?php }?>
<?php }?>
<?php }?>
<?php }else{ ?>
<?php print $this->product->description; ?>
<?php } ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2022-01-31
@rozhnev

Rewrite in normal language and see where the error is:

<?php 
  if (is_array($this->product->extra_field)){
    foreach($this->product->extra_field as $extra_field){
      if ($extra_field["id"] == 1){
        print $extra_field['value'];
      }
    }
  // } - here is error 
  }else{ 
    print $this->product->description; 
  } 
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question