Simple Star Rating

<?php

$starRating = 2;
$totalStars = 5;
$noStar = $totalStars - $starRating;

$starSymbol = "☆";

$activeStar = '<span class="active">'.$starSymbol.'</span>';
$inActiveStar = '<span>'.$starSymbol.'</span>';

for ($i = 0; $i < $starRating; $i++) { echo $activeStar; }
for ($i = 0; $i < $noStar; $i++) { echo $inActiveStar; }

?>

 

Leave a Reply