通过desc与Textable Class订购

时间:2014-03-07 10:53:02

标签: php class text

我希望它按降序排列数据。

现在数据是这样的:

1
2
3

我想对这样的数据进行排序:

3
2
1

这是代码:

完整代码:http://www.phpkode.com/source/s/textable/textable/textable.class.php

function read_table(){
    $lines = file($this->filename);
    foreach ( $lines as $row ){
        if (strlen($row) > 1){
            $temp = explode("~", $row);
            $temp[count($temp) - 1] = rtrim($temp[count($temp) - 1]);
            $this->table[] = $temp;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

将值推送到数组中,然后使用arsort(),这将创建一个数值按降序排列的数组。