Apologies if this has been asked before but I dont know what the process is called so I dont know how to search for it...
I want to print out the name of the top scorer in an exam. I have built an array that returns the top score:
$tom = 90;
$dick = 80;
$harry = 70;
$n = array($tom, $dick, $harry);
arsort($n);
$keys = array_keys($n);
$top_score_1 = $n[$keys[0]];
echo $top_score_1; //prints 90
However I want it to print the name 'Tom' instead the score. How can I add each persons name to their score so that
echo $top_score_1; //prints Tom
Many thanks for any help,
P
$arr = [["score" => 12, "name" = "xy"]...];