Welcome Guest, Not a member yet? Register   Sign In
Extension to the Table Class
#3

[eluser]Unknown[/eluser]
Or, if you are wanting to stick with table cells instead of the <br/>s in myerman's method:

Code:
/**
* Set columns vertically.  Takes a one-dimensional array as input and creates
* a multi-dimensional array with a depth equal to the number of
* columns.  This allows a single array with many elements to  be
* displayed in a table that has a fixed column count.
* Listings are made vertically instead of horizontally.
*
* @access    public
* @param    array
* @param    int
* @return    void
*/
function make_columns_vertical($array = array(), $col_limit = 0) {        
        if ( ! is_array($array) OR count($array) == 0){
            return FALSE;
        }
        
        // Turn off the auto-heading feature since it's doubtful we
        // will want headings from a one-dimensional array
        $this->auto_heading = FALSE;
        
        if ($col_limit == 0){
            return $array;
        }    
        
        $per_column = intval(count($array)/$col_limit);
        $new = array();
        $string = '';
        $step_count = 0;
        
        foreach ($array AS $value) $clean[] = $value;
        for ($i=1; $i <= $col_limit; $i++){
            for ($j=0; $j <= $per_column; $j++){
                $new[$j][$i] = $clean[$step_count];
                $step_count++;
            }
        }
        
        return $new;
}


Messages In This Thread
Extension to the Table Class - by El Forum - 04-30-2008, 10:16 AM
Extension to the Table Class - by El Forum - 04-30-2008, 10:31 AM
Extension to the Table Class - by El Forum - 02-01-2010, 11:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB