My final code for this issue:
<?php if( have_rows('modules') ): ?>
<ul>
<?php while ( have_rows('modules') ) : the_row();
if( get_row_layout() == 'photo' ):
echo '<li>'.the_sub_field('menu_name') . '<li>';
elseif( get_row_layout() == 'text' ):
echo '<li>' . the_sub_field('menu_name') .'</li>';
endif; endwhile; ?>
</ul>
<?php endif; // end modules has rows ?>
It works perfectly. Thanks ractoon for your help. It was more easier when i was trying to do it 🙂