Can someone please help me with sorting this array from smallest to biggest average in PHP and then it should print only smallest and biggest values in another array?
Explanation of the code will be very appreciated!
Thanks!
$students = [
['name' => $name1, 'surname' => $surname1, 'avg' => $avg1],
['name' => $name2, 'surname' => $surname2, 'avg' => $avg2],
['name' => $name3, 'surname' => $surname3, 'avg' => $avg3],
['name' => $name4, 'surname' => $surname4, 'avg' => $avg4],
['name' => $name5, 'surname' => $surname5, 'avg' => $avg5]
];
uasort may provide a solution with the help of a comparison function: