Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create FontAwesome static rating bar based on rating data
function createFontAwesomeStarRating($rating=0,$min=0,$max=10,$maxStars=5,$return=false){
$score=(($rating - $min) * ($maxStars)) / ($max - $min) ;
$result='<div class="rating-stars" title="'.$score.'">';
$result.=str_repeat('<i class="fa fa-star"></i>',$full);
$result.=str_repeat('<i class="fa fa-star-half-o"></i>',$half);
$result.=str_repeat('<i class="fa fa-star-o"></i>',$empty);
return $result;
echo $result;
// OR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.