There are 2 arrays: an array with groups for fields Array ([0] => Array ([id] => 2 [title] => Cars [description] => Fields with characteristics for cars))
[1] => Array ( [id] => 3 [title] => Недвижимость [description] => Группа для полей к объявлениям о недвижимости ) ) and an array for connecting fields that belong to these groups: Array ([0] => Array ([id] => 32 [id_field] => 12 [id_fieldsgroup] => 2)
[1] => Array ( [id] => 33 [id_field] => 12 [id_fieldsgroup] => 3 ) ) How can you compare these two arrays so that when the elements match, all for which $ fgl ['id'] == $ fgff ['id_fieldsgroup'] were selected, I tried to do this, but this is not true:
<div class="col-xs-12"> <select name="id_group[]" multiple="true" id="id_group" class="form-control col-xs-12"> <?php if(!empty($FieldsGroupList)):?> <?php foreach($FieldsGroupList as $fgl): ?> <?php foreach ($getFieldsGroupForField as $fgff): ?> <?php if ($fgl['id'] == $fgff['id_fieldsgroup']): ?> <option value="<?=$fgl['id']?>" selected><?=$fgl['title']?> - <?=$fgl['description']?></option> <?php endif ?> <?php endforeach ?> <?php endforeach ?> <?php else: ?> <option value="0">Нужно создать группы!</option> <?php endif ?> </select> </div> with this code, they are allocated only for which the condition coincided, the rest are not displayed at all, how to fix it ??