I have a page where i need to show star rating system. converting number to visually star image. i have 1.5,2,2.5,..5.0. I have a code shows converting number but 5.0 showing 6 star
followed this code
Converting numbers to visual rating (stars)?
$starNumber = 5.0;
for ($x = 1; $x <= $starNumber; $x++) {
echo '<li><i class="fa fa-star"></i></li>';
}
if (strpos($starNumber, '.')) {
echo '<li><i class="fa fa-star-half-o"></i></li>';
$x++;
}
while ($x <= 5) {
echo '<li><i class="fa fa-star-o"></i></li>';
$x++;
}
Showing as 6 stars