ConFoo Montreal 2026: Call for Papers

Voting

: min(eight, one)?
(Example: nine)

The Note You're Voting On

mbirth at webwriters dot de
21 years ago
For those who want to natsort a 2d-array on the first element of each sub-array, the following few lines should do the job.

<?php

function natsort2d(&$aryInput) {
$aryTemp = $aryOut = array();
foreach (
$aryInput as $key=>$value) {
reset($value);
$aryTemp[$key]=current($value);
}
natsort($aryTemp);
foreach (
$aryTemp as $key=>$value) {
$aryOut[] = $aryInput[$key];
}
$aryInput = $aryOut;
}

?>

<< Back to user notes page

To Top