PHP 8.4.24 Released!

Voting

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

The Note You're Voting On

richard at happymango dot me dot uk
19 years ago
This is a fixed version of the same function I posted below. Now it will handle duplicate entries in the sorted field. EG: If there were two records that had the name Heathrow it would still work. 

<?php

function record_sort($records, $field, $reverse=false)
{
    $hash = array();
    
    foreach($records as $key => $record)
    {
        $hash[$record[$field].$key] = $record;
    }
    
    ($reverse)? krsort($hash) : ksort($hash);
    
    $records = array();
    
    foreach($hash as $record)
    {
        $records []= $record;
    }
    
    return $records;
}

?>

<< Back to user notes page

To Top