$ratings = [10,5,7,2];
$max_rating = 10;
//Rating with representation
$rating = getRatings($ratings, $max_rating, true);
//Rating without representation
$rating = getRatings($ratings, $max_rating);
//Only representation
$representation = getRatingsRepresentation(4.8, $max_rating);
/*
avaliação de 0 à 10
*/
$ratings = [
11,
10,
1,
7,
6,
5,
5,
0,
];
$max_rating = 10;
$rating = getRatings($ratings, $max_rating, true);
print_r($rating);
Array
(
[total_ratings] => 7
[rating] => 4.8571428571429
[max_rating] => 10
[invalid_ratings] => 1
[representation] => Array
(
[0] => Array
(
[type] => full
)
[1] => Array
(
[type] => full
)
[2] => Array
(
[type] => full
)
[3] => Array
(
[type] => full
)
[4] => Array
(
[type] => half
)
[5] => Array
(
[type] => none
)
[6] => Array
(
[type] => none
)
[7] => Array
(
[type] => none
)
[8] => Array
(
[type] => none
)
[9] => Array
(
[type] => none
)
[10] => Array
(
[type] => none
)
)
)
$representation = getRatingsRepresentation(4.8, $max_rating);
print_r($representation);
Array
(
[0] => Array
(
[type] => full
)
[1] => Array
(
[type] => full
)
[2] => Array
(
[type] => full
)
[3] => Array
(
[type] => full
)
[4] => Array
(
[type] => half
)
[5] => Array
(
[type] => none
)
[6] => Array
(
[type] => none
)
[7] => Array
(
[type] => none
)
[8] => Array
(
[type] => none
)
[9] => Array
(
[type] => none
)
[10] => Array
(
[type] => none
)
)