Welcome Guest, Not a member yet? Register   Sign In
Html table plugin
#2

[eluser]sophistry[/eluser]
hi xwero,

thanks for that.

here's a more readable way to get the "NBSP stuffed" columns. i'm a "library" coder so when i saw what you were doing in the while loop i thought "array_chunk, array_pad".

also, is_num() function made my output into a blank page, so i changed it to is_numeric().

Code:
function table($view_path,$body,$header= array(),$footer = array(),$columns=0)
    {
        if( ! is_array($body))
        {
            return '';
        }
        // return $header and $footer parameters to default state in case a
        // developer used a string when calling the function
        if( ! is_array($header)){ $header = array(); }
    
        if( ! is_array($footer)){ $footer = array(); }
        // create columns from single array
        if(is_numeric($columns) && $columns > 0)
        {
            $chunked = array_chunk($body,$col);
            $body = array_pad(array_pop($chunked),$col,' ');
        }
        ob_start();
        include($view_path);
        return ob_get_clean();
    }


Messages In This Thread
Html table plugin - by El Forum - 03-11-2009, 08:14 AM
Html table plugin - by El Forum - 03-11-2009, 12:40 PM
Html table plugin - by El Forum - 03-11-2009, 12:52 PM
Html table plugin - by El Forum - 03-12-2009, 11:56 AM
Html table plugin - by El Forum - 03-12-2009, 01:58 PM
Html table plugin - by El Forum - 03-12-2009, 03:01 PM
Html table plugin - by El Forum - 03-12-2009, 03:48 PM
Html table plugin - by El Forum - 03-12-2009, 06:52 PM
Html table plugin - by El Forum - 03-13-2009, 03:01 AM
Html table plugin - by El Forum - 03-13-2009, 07:47 AM
Html table plugin - by El Forum - 03-13-2009, 08:10 AM
Html table plugin - by El Forum - 03-13-2009, 10:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB