I have an IMDB (Internet Movie Data Base) number, in which case the number is 7.7 out of 10. I need to put this number on a scale of 0 to 5 (integers only). Based on this response: link
I used:
$res = ($obj->imdbRating / 100) * 5;
But the result gives: 0.385 which is not the actual note of the movie (7.7).
What am I doing wrong?
Fixed code with the help of marcelo-bonifazio : / p>
function imdb($filme) {
$url = 'http://www.omdbapi.com/?i=&t=' . strtolower(str_replace(' ', '+', $filme));
$json = file_get_contents($url);
$obj = json_decode($json);
$res = round($obj->imdbRating / 2,0);
return $res;
}
Thank you very much.