I’m trying to modify a PHP template without understanding this language. I have a piece of code that adds a new row to the table with different icons depending on the ‘yes/no’ value. What I’m trying to achieve is to hide or skip entirely rows that have all ‘no’ values. I understand that I have to use a variable like “is there a yes” and loop through all values before ‘printing’ them but I find it challenging to write it in an efficient manner.
Here’s the excerpt of the code:
<?php
if($features) {
foreach ($features as $key => $feature){ ?>
<tr>
<th scope="row"><?php echo esc_html( ucwords(str_replace('packagefeature', '', str_replace('_', ' ', $key)))) ?></th>
<?php foreach ($feature as $key => $value){ ?>
<td>
<?php if ($value == 'yes') {?>
<i class="far fa-check"></i>
<?php } else{ ?>
<i class="far fa-times"></i>
<?php } ?>
</td>
<?php } ?>
</tr>
<?php }
} ?>
I appreciate your time very much and wish you all the best!
Best regards, Max.
