I'm trying to take a text file containing NBA player stats, calculate new variables from those stats, create a new multi-dimensional array from that, and then sort by statistical category and calculate still more variables based on their rank in each category. Make sense? 😉
(here is the file: http://www.hoopscitylive.com/v2.0/01-02NBA.txt)
So far, i have successfully read the file, and calculated their shooting percentages and $stat per 48 minutes. After each player's new variables are calculated, i feed them into an array like so:
$stats = array();
for ($i=0; $i<$player_count; $i++) {
$line = explode("|",$file[$i]);
$name = $line[0];
$pts = $line[1];
$reb = $line[2];
$ast = $line[3];
#...etc.
$stats[$name][pts] = "$pts";
$stats[$name][reb] = "$reb";
$stats[$name][ast] = "$ast";
#...etc.
}
First of all, is that correct?
Second, now I'm stuck. I need to figure out how to sort the array by each stat category to determine their overall rank in that category. Then I will use that ranking to calculate a new variable. Can anyone get me started in the right direction? Thanks!
Mike Aparicio