Jump to content

Simple Array Help


johnsmith153

Recommended Posts

I need to sort in order based on Score A and Score B

 

Score A is most important, but if Score A is tied, then Score B decides their position.

 


$Name = array();
$ScoreA = array();
$ScoreB = array();

$Name[]="John";
$Name[]="David";
$Name[]="Ben";
$Name[]="Steve";

$ScoreA[]="6";
$ScoreA[]="6";
$ScoreA[]="3";
$ScoreA[]="9";

$ScoreB[]="7";
$ScoreB[]="4";
$ScoreB[]="3";
$ScoreB[]="2";

array_multisort($ScoreA,SORT_NUMERIC,SORT_DESC, $ScoreB,SORT_NUMERIC,SORT_DESC);
foreach($Name as $valuetoshow){echo $valuetoshow."<br>";}

//should return:
//Steve
//John
//David
//Ben

//BUT DOESN'T

 

What have I done wrong?

Link to comment
https://forums.phpfreaks.com/topic/122894-simple-array-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.