<?php for ($rcnt=0; $rcnt<$product_rating; $rcnt++) { ?> <i class="fa fa-star has-star" aria-hidden="true"></i> <?php } for($star_blank=0; $star_blank < (5-$product_rating); $star_blank++){ ?> <i class="fa fa-star-o" aria-hidden="true"></i> <?php } ?>