$characters = [
"Character1" => ["Strength" => 1, "Dexterity" => 2,
"Intelligence" => 6, "Wisdom" => 6, "Charisma" => 3],
"Character2" => ["Strength" => 5, "Dexterity" => 4,
"Intelligence" => 1, "Wisdom" => 1, "Charisma" => 6],
"Character3" => ["Strength" => 6, "Dexterity" => 5,
"Intelligence" => 5, "Wisdom" => 1, "Charisma" => 5]
"Character4" => ["Strength" => 1, "Dexterity" => 2,
"Intelligence" => 4, "Wisdom" => 3, "Charisma" => 3]
];
So my question is as follows, how can I get the highest quality of each character. Like for Character1 it would be either Intelligence or Wisdom. I would like to echo the name of the character, the best quality and the value associated with the quality.
foreach($attributs as $s_key => $value)
{
if($value > $max)
$max = max($attributs);
$maxkey = $s_key;
}
echo "<li>$max , $maxkey</li>";
echo "</ul>";
I also have this code, but it only gives me the highest number for each character without giving me the name of the quality associated with the number.
foreach($characters as $names => $quality){
echo "$names";
echo max($quality);
}
I know none of them work at all, but that's as close as I could get to what I wanted.