Order a foreach, by the value of a calculation of values in the array
- by Mark
I have an array as follows:
$players = array(
$player = array(
'name' => 'playername',
'speed' => '10',
'agility' => '10',
'influence' => '10'
)
etc
Then I calculate a $score, based on the sum of speed, agility and influence.
$score = $p['speed'] + $p['agility'] + $p['influence'];
How can I loop through my array, but order the results from highest to lowest $score?
PS- http://pastebin.com/eUEQ5y4u