<ul> <? foreach( $menu as $li ){ ?> ?><li><?= $li['text'] ?> <ul class="<?= $li['active'] ? 'active' : '' ?>"> ... </ul><? <? } ?> </ul>