There is a cycle:
foreach ($attribute_groups as $attribute_group) { echo $attribute_group['name']; foreach ($attribute_group['attribute'] as $attribute) { echo $attribute['name']; echo $attribute['text']; } } I know that in the $attribute_group array, how can I check the value of $attribute_group['name'] before the loop? For example, you need the if ($attribute_group['name']) condition to do one, if not, then another, etc. I know that the $attribute_group array is declared in a loop, but how do I get $attribute_group['name'] before this loop? Separate cycle? Then tell me how to implement it correctly, thank you.
Updated question
In general, I decided to check the condition in the loop, this is how I want to do
<?php if($attribute_groups) { ?> <?php foreach ($attribute_groups as $attribute_group) { ?> <?php if ($attribute_group['name']=='Технические характеристики') { ?> <div class="tab-pane" id="tab-harakter"> <table class="table"> <?php foreach ($attribute_group['attribute'] as $attribute) { ?> <tr> <td><?php echo $attribute['name']; ?></td> <td><?php echo $attribute['text']; ?></td> </tr> <?php } ?> </table> </div> <?php } else { ?> <p>Технические характеристики отсутствуют</p> <?php } ?> <?php if ($attribute_group['name']=='Документы') { ?> <div class="tab-pane" id="tab-doc"> <table class="table"> <?php foreach ($attribute_group['attribute'] as $attribute) { ?> <tr> <td><?php echo $attribute['name']; ?></td> <td><?php echo $attribute['text']; ?></td> </tr> <?php } ?> </table> </div> <?php } else { ?> <p>Документация отсутствует</p> <?php } ?> <?php if ($attribute_group['name']=='Сертификаты') { ?> <div class="tab-pane" id="tab-sertif"> <table class="table"> <?php foreach ($attribute_group['attribute'] as $attribute) { ?> <tr> <td><?php echo $attribute['name']; ?></td> <td><?php echo $attribute['text']; ?></td> </tr> <?php } ?> </table> </div> <?php } else { ?> <p>Сертификаты отсутствуют</p> <?php } ?> <?php } ?> <?php } ?> But it displays incorrectly on the page, I blame it on the fact that I am doing a wrong check in the loop, tell me what is wrong?
$attribute_groupis a member of$attribute_groupsvalues of$attribute_group['name']will be several. Which one do you want to check? If each is only in a cycle, if there is some specific$i-th (for example, the first one), then contact directly the$attribute_groups[$i]['name']index - tutankhamun$attribute_group['name'], depending on this value, I output the relevant information, but my cycle is dynamic and therefore the values of$attribute_group['name']may not be there, so I can't do it . I will come home a little specific question. - Denis