Name: Anonymous 2014-01-25 18:09
this seems like it should be really easy but I'm a beginner and it's giving me trouble
this program is supposed to take the track ratings for any album from the website RateYourMusic.com and average them
I put all the ratings in an single-dimension array called $numbers
so, say an album has 10 songs and four different people have rated it
that array will be 40 values long
the variable $tracks will equal 10 because the album has 10 tracks
this is the code that's supposed to return an array with the average track ratings (an array that will be 10 values long):
for ($x = 0; $x < $tracks; $x++) {
$ratings[$x] += $numbers[$x * $tracks];
}
I feel like I must be overlooking something obvious... anyway let me know if you have any suggestions or if you see what I'm doing wrong. thanks in advance!
this program is supposed to take the track ratings for any album from the website RateYourMusic.com and average them
I put all the ratings in an single-dimension array called $numbers
so, say an album has 10 songs and four different people have rated it
that array will be 40 values long
the variable $tracks will equal 10 because the album has 10 tracks
this is the code that's supposed to return an array with the average track ratings (an array that will be 10 values long):
for ($x = 0; $x < $tracks; $x++) {
$ratings[$x] += $numbers[$x * $tracks];
}
I feel like I must be overlooking something obvious... anyway let me know if you have any suggestions or if you see what I'm doing wrong. thanks in advance!