Sortieren Sie Einzelelementreihen eines 2D-Arrays
Posted: 28 Jan 2025, 02:56
Ich kämpfe darum, dieses Array zu sortieren. < /p>
Es handelt sich
und auch krsort () , aber ohne Glück.
Es handelt sich
Code: Select all
$distanceArray[] = array($attractionID => $tempDistance);
< /code>
Die Ausgabe: < /p>
Array
(
[0] => Array (
[4] => 114.4
)
[1] => Array (
[3] => 16.1
)
[2] => Array (
[2] => 15
)
[3] => Array (
[1] => 21.4
)
)
< /code>
Ich habe dies ohne Glück versucht: < /p>
function cmp($a, $b)
{
return $a['tempDistance'] - $b['tempDistance'];
}
usort($distanceArray, "cmp");