Re: PHP sort from a database variable..?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ok, add the following lines to your ingress.lib-file:

/***********************/
    // converts any array to an instance of the ingress-class
    function array2IngressClass($array)
    {
        $inst = new ingress();
        while(list($key, $val) = each($array))
            $inst->$key = $val;
        return $inst;
    }
    
    // converts any class into an array
    function class2Arr($class)
    {
        return (array)$class;
    }
    
    // sorts arrays comeing from hentIngresser() descending
    function sortClassArray($array)
    {
        $arr = array();
        $sArr = array();
        foreach($array as $ent)
        {
            $arr[] = class2Arr($ent);
            $sArr[] = $ent->publisertLang;
        }
        
        array_multisort($arr, SORT_DESC, $sArr);
        
        $cM = count($arr);
        for($c = 0; $c < $cM; $c++)
            $arr[$c] = array2IngressClass($arr[$c]);
        
        return $arr;
    }


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux