Jump to content

Sorting a list?


Cobalt.Board

Recommended Posts

try this

<?php
$delimiter="\t";
$lines=file($settings['logfile']);
foreach($lines as $K => $line)
{
$lines[$K] = explode($delimiter,$line);
}

usort($lines, "cmp");

foreach($lines as $K => $line)
{
list($name,$from,$email,$url,$comment,$added,$isprivate,$reply)= $line;
echo "$name,$from,$email,$url,$comment,$added,$isprivate,$reply\n";
}

function cmp($a, $b)
{
    return strcmp($a[4], $b[4]);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/166719-sorting-a-list/#findComment-879178
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.