PHP 8.5.0 Alpha 4 available for testing

Voting

: two plus four?
(Example: nine)

The Note You're Voting On

mike at clear-link dot com
17 years ago
Small typo in the aksort function I just submitted. Here's the entire thing again, with the correction noted:

<?php
function aksort(&$array,$valrev=false,$keyrev=false) {
if (
$valrev) { arsort($array); } else { asort($array); }
$vals = array_count_values($array);
$i = 0;
foreach (
$vals AS $val=>$num) {
$first = array_splice($array,0,$i);
$tmp = array_splice($array,0,$num);
if (
$keyrev) { krsort($tmp); } else { ksort($tmp); }
$array = array_merge($first,$tmp,$array);
unset(
$tmp);
$i = $i+$num;
// Fixed from previous post: $i = $num;
}
}
?>

<< Back to user notes page

To Top