Heb je die hele page gelezen ?
Ik denk toch echt dat dit voorbeeld het ongeveer wel is :
Example 2. usort() example using multi-dimensional array
PHP-code:
function cmp ($a, $b) {
return strcmp($a["fruit"], $b["fruit"]);
}
$fruits[0]["fruit"] = "lemons";
$fruits[1]["fruit"] = "apples";
$fruits[2]["fruit"] = "grapes";
usort($fruits, "cmp");
while (list ($key, $value) = each ($fruits)) {
echo "\$fruits[$key]: " . $value["fruit"] . "\n";
}
When sorting a multi-dimensional array, $a and $b contain references to the first index of the array.
This example would display:
Code:
$fruits[0]: apples
$fruits[1]: grapes
$fruits[2]: lemons