public static function table($data, $params = array())
    {
        $defParams = array(
            'ajax' => false,
            'tfoot' => false,
            'table@' => array('class' => 'table'),
            'thead@' => array(),
            'tbody@' => array(),
            'tfoot@' => array()
        );

        $params = array_merge_recursive($defParams, $params);


        if (is_array($data)) {

            $html = '<table ' . Html::attributes($params['table@']) . '><thead ' . Html::attributes($params['thead@']) . '><tr>';
            foreach (reset($data) as $key => $name) {
                $html .= '<th>' . $key . '</th>';
            }
            $html .= '</tr></thead><tbody>';

            if ($params['ajax'] != true) {

                foreach ($data as $key => $row) {

                    $html .= '<tr>';
                    foreach ($row as $key => $col) {
                        $html .= '<td>' . $col . '</td>';
                    }
                    $html .= '</tr>';
                }
            } else {
                $html .= '<!--AJAXCALL-->';
            }
            $html .= '</tbody>';

            $html .= '</table>';

            return $html;
        }
    }
public static function table($data, $params = array())
    {
        $defParams = array(
            'ajax' => false,
            'tfoot' => false,
            'table@' => array('class' => 'table'),
            'thead@' => array(),
            'tbody@' => array(),
            'tfoot@' => array()
        );

        $params = array_merge_recursive($defParams, $params);


        if (is_array($data)) {

            $html = '<table ' . Html::attributes($params['table@']) . '><thead ' . Html::attributes($params['thead@']) . '><tr>';
            foreach (reset($data) as $key => $name) {
                $html .= '<th>' . $key . '</th>';
            }
            $html .= '</tr></thead><tbody>';

            if ($params['ajax'] != true) {

                foreach ($data as $key => $row) {

                    $html .= '<tr>';
                    foreach ($row as $key => $col) {
                        $html .= '<td>' . $col . '</td>';
                    }
                    $html .= '</tr>';
                }
            } else {
                $html .= '<!--AJAXCALL-->';
            }
            $html .= '</tbody>';

            $html .= '</table>';

            return $html;
        }
    }
public static function table ( $ data , $ params = array ( ) ) { $ defParams = array ( 'ajax' => false , 'tfoot' => false , 'table@' => array ( 'class' => 'table' ) , 'thead@' => array ( ) , 'tbody@' => array ( ) , 'tfoot@' => array ( ) ) ; $ params = array_merge_recursive ( $ defParams , $ params ) ; if ( is_array ( $ data ) ) { $ html = '<table ' . Html :: attributes ( $ params [ 'table@' ] ) . '><thead ' . Html :: attributes ( $ params [ 'thead@' ] ) . '><tr>' ; foreach ( reset ( $ data ) as $ key => $ name ) { $ html .= '<th>' . $ key . '</th>' ; } $ html .= '</tr></thead><tbody>' ; if ( $ params [ 'ajax' ] != true ) { foreach ( $ data as $ key => $ row ) { $ html .= '<tr>' ; foreach ( $ row as $ key => $ col ) { $ html .= '<td>' . $ col . '</td>' ; } $ html .= '</tr>' ; } } else { $ html .= '<!--AJAXCALL-->' ; } $ html .= '</tbody>' ; $ html .= '</table>' ; return $ html ; } }
Generate a table structure

@param $data
@param array $params
@return string
Generate a table structure